botanary 0.5.2 → 0.6.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.
- package/dist/botanary.js +2 -0
- package/package.json +8 -6
- package/dist/bin/botanary.js +0 -25
- package/dist/bin/botanary.js.map +0 -1
- package/dist/src/app-url.js +0 -52
- package/dist/src/app-url.js.map +0 -1
- package/dist/src/cli.js +0 -195
- package/dist/src/cli.js.map +0 -1
- package/dist/src/commands/account.js +0 -171
- package/dist/src/commands/account.js.map +0 -1
- package/dist/src/commands/agent.js +0 -338
- package/dist/src/commands/agent.js.map +0 -1
- package/dist/src/commands/authority.js +0 -634
- package/dist/src/commands/authority.js.map +0 -1
- package/dist/src/commands/mcp.js +0 -163
- package/dist/src/commands/mcp.js.map +0 -1
- package/dist/src/commands/services.js +0 -460
- package/dist/src/commands/services.js.map +0 -1
- package/dist/src/commands/session-writes.js +0 -196
- package/dist/src/commands/session-writes.js.map +0 -1
- package/dist/src/commands/sign.js +0 -311
- package/dist/src/commands/sign.js.map +0 -1
- package/dist/src/commands/system.js +0 -135
- package/dist/src/commands/system.js.map +0 -1
- package/dist/src/commands/tokens.js +0 -36
- package/dist/src/commands/tokens.js.map +0 -1
- package/dist/src/commands/utilities.js +0 -119
- package/dist/src/commands/utilities.js.map +0 -1
- package/dist/src/commands/wallet.js +0 -1013
- package/dist/src/commands/wallet.js.map +0 -1
- package/dist/src/commands/watch.js +0 -259
- package/dist/src/commands/watch.js.map +0 -1
- package/dist/src/completion.js +0 -69
- package/dist/src/completion.js.map +0 -1
- package/dist/src/config-store.js +0 -52
- package/dist/src/config-store.js.map +0 -1
- package/dist/src/context.js +0 -19
- package/dist/src/context.js.map +0 -1
- package/dist/src/errors.js +0 -116
- package/dist/src/errors.js.map +0 -1
- package/dist/src/help/examples.js +0 -904
- package/dist/src/help/examples.js.map +0 -1
- package/dist/src/help/format.js +0 -144
- package/dist/src/help/format.js.map +0 -1
- package/dist/src/help/groups.js +0 -39
- package/dist/src/help/groups.js.map +0 -1
- package/dist/src/install-method.js +0 -50
- package/dist/src/install-method.js.map +0 -1
- package/dist/src/mcp-snippets.js +0 -27
- package/dist/src/mcp-snippets.js.map +0 -1
- package/dist/src/outcome.js +0 -63
- package/dist/src/outcome.js.map +0 -1
- package/dist/src/package-version.js +0 -53
- package/dist/src/package-version.js.map +0 -1
- package/dist/src/parser.js +0 -48
- package/dist/src/parser.js.map +0 -1
- package/dist/src/progress.js +0 -56
- package/dist/src/progress.js.map +0 -1
- package/dist/src/prompt-doc.js +0 -92
- package/dist/src/prompt-doc.js.map +0 -1
- package/dist/src/render/accounts.js +0 -21
- package/dist/src/render/accounts.js.map +0 -1
- package/dist/src/render/activity.js +0 -34
- package/dist/src/render/activity.js.map +0 -1
- package/dist/src/render/agents.js +0 -42
- package/dist/src/render/agents.js.map +0 -1
- package/dist/src/render/balance.js +0 -85
- package/dist/src/render/balance.js.map +0 -1
- package/dist/src/render/banner.js +0 -17
- package/dist/src/render/banner.js.map +0 -1
- package/dist/src/render/chains.js +0 -52
- package/dist/src/render/chains.js.map +0 -1
- package/dist/src/render/colors.js +0 -50
- package/dist/src/render/colors.js.map +0 -1
- package/dist/src/render/gas.js +0 -34
- package/dist/src/render/gas.js.map +0 -1
- package/dist/src/render/grant.js +0 -34
- package/dist/src/render/grant.js.map +0 -1
- package/dist/src/render/kv.js +0 -60
- package/dist/src/render/kv.js.map +0 -1
- package/dist/src/render/mandates.js +0 -111
- package/dist/src/render/mandates.js.map +0 -1
- package/dist/src/render/print.js +0 -18
- package/dist/src/render/print.js.map +0 -1
- package/dist/src/render/redact.js +0 -23
- package/dist/src/render/redact.js.map +0 -1
- package/dist/src/render/table.js +0 -16
- package/dist/src/render/table.js.map +0 -1
- package/dist/src/repl.js +0 -232
- package/dist/src/repl.js.map +0 -1
- package/dist/src/review.js +0 -52
- package/dist/src/review.js.map +0 -1
- package/dist/src/run-installer.js +0 -30
- package/dist/src/run-installer.js.map +0 -1
- package/dist/src/settings.js +0 -88
- package/dist/src/settings.js.map +0 -1
- package/dist/src/update-check.js +0 -91
- package/dist/src/update-check.js.map +0 -1
- package/dist/src/validate.js +0 -138
- package/dist/src/validate.js.map +0 -1
package/dist/src/errors.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { BotanaryApiError } from 'botanary-mcp';
|
|
2
|
-
import { colors, glyphs } from './render/colors.js';
|
|
3
|
-
/**
|
|
4
|
-
* The exit-code contract. Deliberately typed rather than the 0/1 the v1 design chose: a CI step branches
|
|
5
|
-
* on an exit code before it ever pipes through jq, and Botanary has one outcome nobody else's table has
|
|
6
|
-
* (`pending` - a relayed op whose receipt has not arrived, which is neither success nor failure).
|
|
7
|
-
*/
|
|
8
|
-
export const EXIT = {
|
|
9
|
-
ok: 0,
|
|
10
|
-
error: 1,
|
|
11
|
-
invalidArgs: 2,
|
|
12
|
-
notAuthenticated: 3,
|
|
13
|
-
declined: 4,
|
|
14
|
-
pending: 5,
|
|
15
|
-
upstream: 6,
|
|
16
|
-
interrupted: 130,
|
|
17
|
-
};
|
|
18
|
-
/** The same table, in help-print order. Root help renders this verbatim (see src/help/format.ts). */
|
|
19
|
-
export const EXIT_CODES = [
|
|
20
|
-
{ code: EXIT.ok, meaning: 'Success' },
|
|
21
|
-
{ code: EXIT.error, meaning: 'Error' },
|
|
22
|
-
{ code: EXIT.invalidArgs, meaning: 'Invalid arguments' },
|
|
23
|
-
{ code: EXIT.notAuthenticated, meaning: 'Not logged in, or not paired' },
|
|
24
|
-
{ code: EXIT.declined, meaning: 'Declined (policy, bounds, or chain tier)' },
|
|
25
|
-
{ code: EXIT.pending, meaning: 'Pending: relayed, settlement unknown' },
|
|
26
|
-
{ code: EXIT.upstream, meaning: 'Upstream unavailable (network, RPC, bundler)' },
|
|
27
|
-
{ code: EXIT.interrupted, meaning: 'Interrupted (SIGINT)' },
|
|
28
|
-
];
|
|
29
|
-
/**
|
|
30
|
-
* Every failure this CLI reports. `message` is ALWAYS the backend's own words when a backend produced it -
|
|
31
|
-
* re-authoring a decline is how a CLI ends up overstating enforcement that is not live (see the workspace
|
|
32
|
-
* CLAUDE.md's hookless-accounts caveat). `code` is the stable string a script branches on; `hint` is one
|
|
33
|
-
* actionable sentence, never a paragraph.
|
|
34
|
-
*/
|
|
35
|
-
export class CliError extends Error {
|
|
36
|
-
code;
|
|
37
|
-
exit;
|
|
38
|
-
hint;
|
|
39
|
-
constructor(message, code, exit, hint) {
|
|
40
|
-
super(message);
|
|
41
|
-
this.code = code;
|
|
42
|
-
this.exit = exit;
|
|
43
|
-
this.hint = hint;
|
|
44
|
-
this.name = 'CliError';
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export function invalidArgs(message, hint) {
|
|
48
|
-
return new CliError(message, 'invalid_args', EXIT.invalidArgs, hint);
|
|
49
|
-
}
|
|
50
|
-
export function notLoggedIn() {
|
|
51
|
-
return new CliError('Not logged in as the wallet owner.', 'not_logged_in', EXIT.notAuthenticated, 'Run `botanary login` first.');
|
|
52
|
-
}
|
|
53
|
-
export function notPaired() {
|
|
54
|
-
return new CliError('This machine has no agent identity paired with Botanary.', 'not_paired', EXIT.notAuthenticated, 'Run `botanary agent pair` and enter the code in Botanary.');
|
|
55
|
-
}
|
|
56
|
-
/** True for the transport-level failures fetch reports as a plain Error, which carry no HTTP status. */
|
|
57
|
-
function isNetworkError(e) {
|
|
58
|
-
if (!(e instanceof Error))
|
|
59
|
-
return false;
|
|
60
|
-
const code = e.code;
|
|
61
|
-
if (code === 'ENOTFOUND' || code === 'ECONNREFUSED' || code === 'ECONNRESET' || code === 'ETIMEDOUT' || code === 'EAI_AGAIN') {
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
return e.name === 'AbortError' || /fetch failed|network|socket hang up/i.test(e.message);
|
|
65
|
-
}
|
|
66
|
-
function fromApiError(e) {
|
|
67
|
-
// The backend's own typed refusal, when it sent one. Keyed off the guaranteed field rather than the
|
|
68
|
-
// prose, exactly as BotanaryApiError.details' own doc comment asks.
|
|
69
|
-
const declineReason = typeof e.details?.declineReason === 'string' ? e.details.declineReason : null;
|
|
70
|
-
if (e.status === 401 || e.status === 403) {
|
|
71
|
-
return new CliError(e.message, 'not_authenticated', EXIT.notAuthenticated, 'Run `botanary login` again.');
|
|
72
|
-
}
|
|
73
|
-
if (declineReason || e.status === 402) {
|
|
74
|
-
return new CliError(e.message, declineReason ?? 'declined', EXIT.declined, 'Run `botanary diagnose` to see what is blocking this.');
|
|
75
|
-
}
|
|
76
|
-
if (e.status === 404) {
|
|
77
|
-
return new CliError(e.message, 'not_found', EXIT.error);
|
|
78
|
-
}
|
|
79
|
-
if (e.status === 400 || e.status === 422) {
|
|
80
|
-
return new CliError(e.message, 'invalid_args', EXIT.invalidArgs);
|
|
81
|
-
}
|
|
82
|
-
if (e.status === 429) {
|
|
83
|
-
return new CliError(e.message, 'rate_limited', EXIT.upstream, e.retryAfterSeconds != null ? `Retry in ${e.retryAfterSeconds}s.` : 'Try again shortly.');
|
|
84
|
-
}
|
|
85
|
-
if (e.status >= 500) {
|
|
86
|
-
return new CliError(e.message, 'upstream_unavailable', EXIT.upstream, 'The backend or an upstream RPC is unavailable. Try again shortly.');
|
|
87
|
-
}
|
|
88
|
-
return new CliError(e.message, 'error', EXIT.error);
|
|
89
|
-
}
|
|
90
|
-
/** Normalize anything a command threw into the one type cli.ts knows how to report. */
|
|
91
|
-
export function toCliError(e) {
|
|
92
|
-
if (e instanceof CliError)
|
|
93
|
-
return e;
|
|
94
|
-
if (e instanceof BotanaryApiError)
|
|
95
|
-
return fromApiError(e);
|
|
96
|
-
if (isNetworkError(e)) {
|
|
97
|
-
return new CliError(e instanceof Error ? e.message : String(e), 'upstream_unavailable', EXIT.upstream, 'Check your connection, or `botanary config` for the API URL in use.');
|
|
98
|
-
}
|
|
99
|
-
return new CliError(e instanceof Error ? e.message : String(e), 'error', EXIT.error);
|
|
100
|
-
}
|
|
101
|
-
/** The `--json` failure contract. Successful output stays the bare payload: a zero exit already says ok. */
|
|
102
|
-
export function errorEnvelope(err) {
|
|
103
|
-
return {
|
|
104
|
-
ok: false,
|
|
105
|
-
error: { code: err.code, message: err.message, ...(err.hint ? { hint: err.hint } : {}) },
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
/** The human failure shape the v1 design spec §7 promised: the reason, the machine code, the next step. */
|
|
109
|
-
export function errorLines(err) {
|
|
110
|
-
const label = err.exit === EXIT.declined ? 'declined' : 'error';
|
|
111
|
-
const lines = [glyphs.danger(`${label}: ${err.message}`), colors.dim(` code: ${err.code}`)];
|
|
112
|
-
if (err.hint)
|
|
113
|
-
lines.push(` ${err.hint}`);
|
|
114
|
-
return lines;
|
|
115
|
-
}
|
|
116
|
-
//# sourceMappingURL=errors.js.map
|
package/dist/src/errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,EAAE,EAAE,CAAC;IACL,KAAK,EAAE,CAAC;IACR,WAAW,EAAE,CAAC;IACd,gBAAgB,EAAE,CAAC;IACnB,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,WAAW,EAAE,GAAG;CACR,CAAC;AAEX,qGAAqG;AACrG,MAAM,CAAC,MAAM,UAAU,GAA6C;IAClE,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;IACrC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE;IACtC,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,mBAAmB,EAAE;IAC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