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
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { colors } from './colors.js';
|
|
2
|
-
import { amount, columns, dash, section, shortTime } from './kv.js';
|
|
3
|
-
const DELEGATION_HEADERS = ['ID', 'STATUS', 'CHAIN', 'WHAT IT ALLOWS', 'BUDGET USED', 'EXPIRES'];
|
|
4
|
-
const MANDATE_HEADERS = ['ID', 'AGENT ADDRESS', 'CHAIN', 'POLICY', 'STATUS', 'CREATED'];
|
|
5
|
-
/** The caveat the design spec requires stated inline, matching the workspace CLAUDE.md's live caveat. */
|
|
6
|
-
const CAVEAT = 'Mandates are testnet-only and pre-mainnet. Nothing here is enforced on mainnet yet.';
|
|
7
|
-
/** The caveat about owner-lane rules not being enforced on-chain today. */
|
|
8
|
-
const OWNER_RULES_CAVEAT = 'Owner-lane rules are not enforced on-chain on accounts created since 2026-07-30. They remain available for future use.';
|
|
9
|
-
function statusCell(status) {
|
|
10
|
-
if (status === 'active')
|
|
11
|
-
return colors.success('active');
|
|
12
|
-
if (status === 'revoked' || status === 'expired' || status === 'paused')
|
|
13
|
-
return colors.muted(String(status));
|
|
14
|
-
return dash(status);
|
|
15
|
-
}
|
|
16
|
-
function budgetCell(meters) {
|
|
17
|
-
if (!Array.isArray(meters) || !meters.length)
|
|
18
|
-
return '-';
|
|
19
|
-
return meters
|
|
20
|
-
.map((meter) => `${amount(meter.spent)}/${amount(meter.limit)} ${dash(meter.token?.symbol)}`)
|
|
21
|
-
.join(', ');
|
|
22
|
-
}
|
|
23
|
-
export function mandateRows(payload) {
|
|
24
|
-
const delegations = payload?.delegations;
|
|
25
|
-
const list = Array.isArray(delegations) ? delegations : [];
|
|
26
|
-
return list
|
|
27
|
-
.filter((delegation) => delegation !== null && typeof delegation === 'object')
|
|
28
|
-
.map((delegation) => [
|
|
29
|
-
dash(delegation.id),
|
|
30
|
-
statusCell(delegation.status),
|
|
31
|
-
dash(delegation.chain),
|
|
32
|
-
// The backend's own sentence, never re-authored: it is the only description of the bound that cannot
|
|
33
|
-
// drift into overstating what is actually enforced.
|
|
34
|
-
dash(delegation.humanSummary),
|
|
35
|
-
budgetCell(delegation.spentToDate),
|
|
36
|
-
delegation.policySet?.expiresAt ? shortTime(delegation.policySet.expiresAt) : '-',
|
|
37
|
-
]);
|
|
38
|
-
}
|
|
39
|
-
export function onchainMandateRows(mandates) {
|
|
40
|
-
const list = Array.isArray(mandates) ? mandates : [];
|
|
41
|
-
return list
|
|
42
|
-
.filter((mandate) => mandate !== null && typeof mandate === 'object')
|
|
43
|
-
.map((mandate) => [
|
|
44
|
-
dash(mandate.id),
|
|
45
|
-
dash(mandate.delegateeAddress),
|
|
46
|
-
dash(mandate.chainId),
|
|
47
|
-
dash(mandate.policySummary),
|
|
48
|
-
statusCell(mandate.status),
|
|
49
|
-
mandate.createdAt ? shortTime(mandate.createdAt) : '-',
|
|
50
|
-
]);
|
|
51
|
-
}
|
|
52
|
-
export function renderMandates(payload) {
|
|
53
|
-
const delegationRows = mandateRows(payload);
|
|
54
|
-
const mandatesData = payload?.mandates;
|
|
55
|
-
const mandateList = Array.isArray(mandatesData?.mandates) ? mandatesData.mandates : [];
|
|
56
|
-
const mandateRowsList = onchainMandateRows(mandateList);
|
|
57
|
-
const accountRules = mandatesData?.rules;
|
|
58
|
-
const rulesSummary = accountRules?.summary;
|
|
59
|
-
const blocks = [colors.warning(`⚠ ${CAVEAT}`)];
|
|
60
|
-
// Delegations section
|
|
61
|
-
blocks.push('');
|
|
62
|
-
blocks.push(section('Delegations (Smart Sessions)'));
|
|
63
|
-
if (delegationRows.length) {
|
|
64
|
-
blocks.push(columns(DELEGATION_HEADERS, delegationRows));
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
blocks.push(colors.muted(' No delegations on this account.'));
|
|
68
|
-
}
|
|
69
|
-
// On-chain mandates section
|
|
70
|
-
blocks.push('');
|
|
71
|
-
blocks.push(section('Mandates (on-chain)'));
|
|
72
|
-
if (mandateRowsList.length) {
|
|
73
|
-
blocks.push(columns(MANDATE_HEADERS, mandateRowsList));
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
blocks.push(colors.muted(' No mandates on this account.'));
|
|
77
|
-
}
|
|
78
|
-
// Rules summary section - only if summary exists and has meaningful (non-zero) content
|
|
79
|
-
if (rulesSummary) {
|
|
80
|
-
const rulesRows = [];
|
|
81
|
-
if (typeof rulesSummary.weeklyLimit === 'number' && rulesSummary.weeklyLimit > 0) {
|
|
82
|
-
rulesRows.push(['Weekly limit', `${amount(rulesSummary.weeklyLimit)}`]);
|
|
83
|
-
}
|
|
84
|
-
if (typeof rulesSummary.weeklySpent === 'number' && rulesSummary.weeklySpent > 0) {
|
|
85
|
-
rulesRows.push(['Weekly spent', `${amount(rulesSummary.weeklySpent)}`]);
|
|
86
|
-
}
|
|
87
|
-
if (typeof rulesSummary.allowContracts === 'number' && rulesSummary.allowContracts > 0) {
|
|
88
|
-
rulesRows.push(['Allowed contracts', String(rulesSummary.allowContracts)]);
|
|
89
|
-
}
|
|
90
|
-
if (typeof rulesSummary.denyContracts === 'number' && rulesSummary.denyContracts > 0) {
|
|
91
|
-
rulesRows.push(['Denied contracts', String(rulesSummary.denyContracts)]);
|
|
92
|
-
}
|
|
93
|
-
if (typeof rulesSummary.allowRecipients === 'number' && rulesSummary.allowRecipients > 0) {
|
|
94
|
-
rulesRows.push(['Allowed recipients', String(rulesSummary.allowRecipients)]);
|
|
95
|
-
}
|
|
96
|
-
if (rulesRows.length) {
|
|
97
|
-
blocks.push('');
|
|
98
|
-
blocks.push(section('Owner rules (policy caps)'));
|
|
99
|
-
blocks.push(rulesRows.map(([k, v]) => ` ${k.padEnd(20)} ${v}`).join('\n'));
|
|
100
|
-
blocks.push(colors.dim(` ${OWNER_RULES_CAVEAT}`));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
// Empty state message when truly nothing is granted (no delegations, mandates, or rules)
|
|
104
|
-
if (!delegationRows.length && !mandateRowsList.length && !rulesSummary) {
|
|
105
|
-
blocks.push('');
|
|
106
|
-
blocks.push(colors.muted(' Nothing granted to the agent lane on this account.'));
|
|
107
|
-
blocks.push(colors.dim(' `botanary mandates suggest` proposes a starting point.'));
|
|
108
|
-
}
|
|
109
|
-
return blocks.join('\n');
|
|
110
|
-
}
|
|
111
|
-
//# sourceMappingURL=mandates.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mandates.js","sourceRoot":"","sources":["../../../src/render/mandates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAyCpE,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;AACjG,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAExF,yGAAyG;AACzG,MAAM,MAAM,GAAG,qFAAqF,CAAC;AAErG,2EAA2E;AAC3E,MAAM,kBAAkB,GAAG,wHAAwH,CAAC;AAEpJ,SAAS,UAAU,CAAC,MAAe;IACjC,IAAI,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACzD,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7G,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC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AAE,CAAC,CAAC;QAChB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC,CAAC;QAClF,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAC,CAAC;IACtF,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC"}
|
package/dist/src/render/print.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* One printer, three modes. `--json` is the machine contract and wins over everything (including the
|
|
3
|
-
* implicit --json a pipe brings). `--raw` is the human escape hatch that keeps 0.1.0's pretty-JSON dump
|
|
4
|
-
* reachable. Otherwise the view renderer runs - which is the whole point: 0.1.0 printed ~40 KB of JSON to
|
|
5
|
-
* a terminal for `balance`.
|
|
6
|
-
*/
|
|
7
|
-
export function printResult(ctx, data, render) {
|
|
8
|
-
if (ctx.json) {
|
|
9
|
-
console.log(JSON.stringify(data));
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
if (ctx.raw || !render) {
|
|
13
|
-
console.log(typeof data === 'string' ? data : JSON.stringify(data, null, 2));
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
console.log(render(data));
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=print.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"print.js","sourceRoot":"","sources":["../../../src/render/print.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,GAAe,EAAE,IAAa,EAAE,MAAkC;IAC5F,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAClC,OAAO;IACT,CAAC;IACD,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC7E,OAAO;IACT,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { redactUnknown } from 'botanary-mcp';
|
|
2
|
-
/** Wraps botanary-mcp's own redactUnknown: masks `secret` wherever it appears inside `value` unless
|
|
3
|
-
* `reveal` is true. redactUnknown always returns a STRING (it's built for safe-to-log text), so for
|
|
4
|
-
* any non-string value this round-trips through JSON to redact the secret in place while preserving
|
|
5
|
-
* the value's shape - critical for --json mode, where the caller wants a redacted clone, not a
|
|
6
|
-
* flattened "[object Object]". Falls back to the flattened form only if the value can't round-trip
|
|
7
|
-
* through JSON (e.g. contains a function or a circular reference) - still safe (the secret is still
|
|
8
|
-
* masked), just loses shape in that edge case. */
|
|
9
|
-
export function redactForDisplay(value, secret, reveal) {
|
|
10
|
-
if (reveal || !secret)
|
|
11
|
-
return value;
|
|
12
|
-
if (typeof value === 'string')
|
|
13
|
-
return redactUnknown(value, secret);
|
|
14
|
-
try {
|
|
15
|
-
const serialized = JSON.stringify(value);
|
|
16
|
-
const masked = redactUnknown(serialized, secret);
|
|
17
|
-
return JSON.parse(masked);
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return redactUnknown(value, secret);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=redact.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../../../src/render/redact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C;;;;;;mDAMmD;AACnD,MAAM,UAAU,gBAAgB,CAAC,KAAc,EAAE,MAAiC,EAAE,MAAe;IACjG,IAAI,MAAM,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACnE,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACzC,MAAM,MAAM,GAAG,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;AACH,CAAC"}
|
package/dist/src/render/table.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import Table from 'cli-table3';
|
|
2
|
-
/** Borderless aligned two-column table (the `config list` reference look) - not a bordered grid. */
|
|
3
|
-
export function renderTable(rows) {
|
|
4
|
-
const table = new Table({
|
|
5
|
-
chars: {
|
|
6
|
-
top: '', 'top-mid': '', 'top-left': '', 'top-right': '',
|
|
7
|
-
bottom: '', 'bottom-mid': '', 'bottom-left': '', 'bottom-right': '',
|
|
8
|
-
left: '', 'left-mid': '', mid: '', 'mid-mid': '',
|
|
9
|
-
right: '', 'right-mid': '', middle: ' ',
|
|
10
|
-
},
|
|
11
|
-
style: { 'padding-left': 0, 'padding-right': 4, border: [], head: [] },
|
|
12
|
-
});
|
|
13
|
-
table.push(...rows);
|
|
14
|
-
return table.toString();
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=table.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","sourceRoot":"","sources":["../../../src/render/table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAE/B,oGAAoG;AACpG,MAAM,UAAU,WAAW,CAAC,IAAwB;IAClD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC;QACtB,KAAK,EAAE;YACL,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE;YACvD,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE;YACnE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE;YAChD,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG;SACxC;QACD,KAAK,EAAE,EAAE,cAAc,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;KACvE,CAAC,CAAC;IACH,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IACpB,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;AAC1B,CAAC"}
|
package/dist/src/repl.js
DELETED
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import readline from 'node:readline';
|
|
2
|
-
import { CommanderError } from 'commander';
|
|
3
|
-
import { botanaryMcpHome } from 'botanary-mcp';
|
|
4
|
-
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
5
|
-
import { join } from 'node:path';
|
|
6
|
-
import { parseLine } from './parser.js';
|
|
7
|
-
import { renderBanner } from './render/banner.js';
|
|
8
|
-
import { colors } from './render/colors.js';
|
|
9
|
-
/** Words the REPL itself answers, which are not commands on the program. */
|
|
10
|
-
const REPL_WORDS = ['help', 'clear', 'exit', 'quit', '?'];
|
|
11
|
-
/** Global flags that must be set at startup, not per REPL line. */
|
|
12
|
-
const GLOBAL_FLAGS = new Set([
|
|
13
|
-
'--json', '--raw', '--quiet', '--verbose', '--no-color', '--no-interactive',
|
|
14
|
-
'--reveal', '--chain', '--account', '--api-url', '--home', '--profile', '--timeout', '--debug', '--yes', '--dry-run',
|
|
15
|
-
'-q', '-y',
|
|
16
|
-
]);
|
|
17
|
-
/**
|
|
18
|
-
* `botanary balance` typed INSIDE the REPL used to fail with "unknown command 'botanary'" - the exact
|
|
19
|
-
* papercut the Alchemy CLI reference has too. People type the program name out of habit; stripping it is
|
|
20
|
-
* three lines and removes a guaranteed first-run error.
|
|
21
|
-
*/
|
|
22
|
-
export function normalizeReplLine(line) {
|
|
23
|
-
const trimmed = line.trim().replace(/\s+/g, ' ');
|
|
24
|
-
if (trimmed === '?')
|
|
25
|
-
return 'help';
|
|
26
|
-
if (trimmed === 'botanary')
|
|
27
|
-
return '';
|
|
28
|
-
if (trimmed.startsWith('botanary '))
|
|
29
|
-
return trimmed.slice('botanary '.length).trim();
|
|
30
|
-
return trimmed;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Completions from the parser tree rather than a hardcoded list: 0.1.0 kept a second copy of every
|
|
34
|
-
* command name in this file, which drifted the moment a command was added, and only completed at position
|
|
35
|
-
* zero because it returned the whole line as the token being completed.
|
|
36
|
-
*/
|
|
37
|
-
export function replCompletions(program, line) {
|
|
38
|
-
const normalized = normalizeReplLine(line);
|
|
39
|
-
const tokens = parseLine(normalized);
|
|
40
|
-
const trailingSpace = /\s$/.test(line) || normalized === '';
|
|
41
|
-
const partial = trailingSpace ? '' : (tokens[tokens.length - 1] ?? '');
|
|
42
|
-
const consumed = trailingSpace ? tokens : tokens.slice(0, -1);
|
|
43
|
-
let cmd = program;
|
|
44
|
-
for (const token of consumed) {
|
|
45
|
-
const next = cmd.commands.find((c) => c.name() === token || c.aliases().includes(token));
|
|
46
|
-
if (!next)
|
|
47
|
-
break;
|
|
48
|
-
cmd = next;
|
|
49
|
-
}
|
|
50
|
-
const candidates = [
|
|
51
|
-
...cmd.commands.map((c) => c.name()),
|
|
52
|
-
...cmd.options.map((o) => o.long ?? o.short ?? '').filter((f) => f !== ''),
|
|
53
|
-
...(cmd === program ? REPL_WORDS : []),
|
|
54
|
-
];
|
|
55
|
-
const hits = candidates.filter((c) => c.startsWith(partial)).sort();
|
|
56
|
-
return [hits.length ? hits : candidates.sort(), partial];
|
|
57
|
-
}
|
|
58
|
-
const HISTORY_LIMIT = 200;
|
|
59
|
-
const historyPath = () => join(botanaryMcpHome(), 'cli-history');
|
|
60
|
-
async function loadHistory() {
|
|
61
|
-
try {
|
|
62
|
-
const lines = (await readFile(historyPath(), 'utf8')).split('\n').filter((l) => l !== '');
|
|
63
|
-
return lines.slice(0, HISTORY_LIMIT);
|
|
64
|
-
}
|
|
65
|
-
catch {
|
|
66
|
-
return [];
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
async function saveHistory(history) {
|
|
70
|
-
try {
|
|
71
|
-
await mkdir(botanaryMcpHome(), { recursive: true });
|
|
72
|
-
await writeFile(historyPath(), `${history.slice(0, HISTORY_LIMIT).join('\n')}\n`, { encoding: 'utf8', mode: 0o600 });
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
// A REPL that cannot write its history is still a working REPL - never fail the session over it.
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/** A dispatched command (e.g. `send`, `agent spend`) may itself build an interactive prompt via
|
|
79
|
-
* @clack/prompts, which creates its OWN readline interface on this same process.stdin. Verified live:
|
|
80
|
-
* two readline interfaces alive on one stdin at once is not just cosmetically risky - the REPL's own
|
|
81
|
-
* keypress listener stays attached and independently reinterprets the user's prompt answers as REPL
|
|
82
|
-
* command lines (e.g. typing "25" into a clack prompt also dispatches a stray "25" command), and
|
|
83
|
-
* closing the inner (clack) interface pauses the shared stdin stream as a side effect, which starves
|
|
84
|
-
* the REPL's still-open outer interface of further input with no way to recover (confirmed: it never
|
|
85
|
-
* sees a subsequent line again, including "exit"). The fix is to never let two interfaces be alive at
|
|
86
|
-
* once: close this interface before dispatching, then build a fresh one once the command settles. */
|
|
87
|
-
function createReplInterface(program, history) {
|
|
88
|
-
return readline.createInterface({
|
|
89
|
-
input: process.stdin,
|
|
90
|
-
output: process.stdout,
|
|
91
|
-
prompt: colors.brand('> '),
|
|
92
|
-
// readline wants most-recent-first, which is the order `history` is maintained in.
|
|
93
|
-
history: [...history],
|
|
94
|
-
removeHistoryDuplicates: true,
|
|
95
|
-
completer: (line) => replCompletions(program, line),
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
export async function runRepl(program, state) {
|
|
99
|
-
const history = await loadHistory();
|
|
100
|
-
console.log(renderBanner('BOTANARY'));
|
|
101
|
-
console.log(`${colors.brand('◆')} ${colors.bold('Welcome to Botanary')}`);
|
|
102
|
-
console.log(state.loggedIn ? `${colors.success('✔')} Logged in` : `${colors.muted('not logged in')} - try \`login\``);
|
|
103
|
-
console.log(colors.dim("Run commands directly (no 'botanary' prefix).\n"));
|
|
104
|
-
console.log(`${colors.brand('◆')} ${colors.bold('Quick commands')}`);
|
|
105
|
-
const quick = state.loggedIn ? ['balance', 'send', 'status'] : ['login', 'agent pair'];
|
|
106
|
-
for (const q of quick)
|
|
107
|
-
console.log(colors.dim(` - ${q}`));
|
|
108
|
-
console.log(colors.dim("Press TAB for autocomplete. Type 'clear' to clear, 'exit' or 'quit' to leave."));
|
|
109
|
-
console.log(colors.dim('Ctrl-C leaves immediately.\n'));
|
|
110
|
-
let savePromise = Promise.resolve();
|
|
111
|
-
await new Promise((resolve) => {
|
|
112
|
-
// The REPL's readline interface gets closed and rebuilt around every dispatched command (see
|
|
113
|
-
// createReplInterface's doc comment), so a *lot* more 'close' events fire than just "the user is
|
|
114
|
-
// leaving" - and a burst of already-buffered lines (a paste, or piped/non-interactive input) can
|
|
115
|
-
// land multiple 'line' events on ONE interface generation before its first line has even been
|
|
116
|
-
// dispatched, so a per-line closure can't just capture "the interface" once and trust it's still
|
|
117
|
-
// current by the time its turn in the queue comes up. `current` always points at whichever
|
|
118
|
-
// interface generation is live right now; every action below goes through it (never through a
|
|
119
|
-
// closure-captured reference) for exactly that reason.
|
|
120
|
-
let current;
|
|
121
|
-
let queue = Promise.resolve();
|
|
122
|
-
let finished = false;
|
|
123
|
-
// True only for the span between closing the current interface to dispatch a command and that
|
|
124
|
-
// command settling - distinguishes "we closed this ourselves, a fresh one is coming" from a real
|
|
125
|
-
// close (exit/quit, or the input stream ending on its own), which the close handler below uses to
|
|
126
|
-
// decide whether this close is news at all.
|
|
127
|
-
let closingForDispatch = false;
|
|
128
|
-
const finish = () => {
|
|
129
|
-
if (finished)
|
|
130
|
-
return;
|
|
131
|
-
finished = true;
|
|
132
|
-
savePromise = saveHistory(history);
|
|
133
|
-
console.log(colors.dim('\nbye.'));
|
|
134
|
-
resolve();
|
|
135
|
-
};
|
|
136
|
-
const attach = (iface) => {
|
|
137
|
-
current = iface;
|
|
138
|
-
iface.on('line', (line) => {
|
|
139
|
-
queue = queue.then(async () => {
|
|
140
|
-
if (finished)
|
|
141
|
-
return;
|
|
142
|
-
const trimmed = normalizeReplLine(line);
|
|
143
|
-
if (trimmed === 'exit' || trimmed === 'quit') {
|
|
144
|
-
current.close();
|
|
145
|
-
finish();
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
if (trimmed === 'clear') {
|
|
149
|
-
// \x1bc is a full terminal reset, which also drops the scrollback the banner filled.
|
|
150
|
-
process.stdout.write('\x1bc');
|
|
151
|
-
current.prompt();
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
if (trimmed) {
|
|
155
|
-
// Check if the line contains a global flag - these must be set at startup, not per REPL line.
|
|
156
|
-
const tokens = parseLine(trimmed);
|
|
157
|
-
for (const rawToken of tokens) {
|
|
158
|
-
// Split on `=` first: `--chain=8453` is valid syntax everywhere else in this CLI, and
|
|
159
|
-
// matching only the bare spelling let that form through silently - which is the exact
|
|
160
|
-
// "typed here, quietly ignored" bug this guard exists to prevent.
|
|
161
|
-
const token = rawToken.split('=')[0];
|
|
162
|
-
if (GLOBAL_FLAGS.has(token)) {
|
|
163
|
-
console.log(colors.warning('Global flags (like ' + token + ') must be set when starting botanary, not per REPL line.\n' +
|
|
164
|
-
' Exit with `quit`, restart with: botanary ' + token + ' ... \n' +
|
|
165
|
-
' Global flags: --json --raw --quiet --verbose --no-color --no-interactive --reveal ' +
|
|
166
|
-
'--chain --account --api-url --home --profile --timeout --debug --yes --dry-run'));
|
|
167
|
-
current.prompt();
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
// A dispatched command may itself open an interactive prompt (e.g. `send`/`agent spend`
|
|
172
|
-
// use @clack/prompts, which builds its OWN readline interface on this same process.stdin).
|
|
173
|
-
// Two live readline interfaces on one stdin fight over raw-mode/keypress state - closing
|
|
174
|
-
// this one first (and building a fresh one once the command settles) keeps exactly one
|
|
175
|
-
// interface alive at a time, never two.
|
|
176
|
-
history.unshift(trimmed);
|
|
177
|
-
if (history.length > HISTORY_LIMIT)
|
|
178
|
-
history.length = HISTORY_LIMIT;
|
|
179
|
-
closingForDispatch = true;
|
|
180
|
-
current.close();
|
|
181
|
-
try {
|
|
182
|
-
await program.parseAsync(parseLine(trimmed), { from: 'user' });
|
|
183
|
-
}
|
|
184
|
-
catch (e) {
|
|
185
|
-
if (e instanceof CommanderError) {
|
|
186
|
-
if (e.exitCode !== 0) {
|
|
187
|
-
console.log(colors.danger(e.message));
|
|
188
|
-
}
|
|
189
|
-
// exitCode === 0 means a successful help/version display (commander already printed it) -
|
|
190
|
-
// nothing more to report, just continue the loop.
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
console.log(colors.danger(e instanceof Error ? e.message : String(e)));
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
finally {
|
|
197
|
-
closingForDispatch = false;
|
|
198
|
-
if (!finished) {
|
|
199
|
-
attach(createReplInterface(program, history));
|
|
200
|
-
current.prompt();
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
current.prompt();
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
iface.on('close', () => {
|
|
209
|
-
if (closingForDispatch)
|
|
210
|
-
return;
|
|
211
|
-
// Not our own transient close: either the exit/quit branch closed it (finish() already ran
|
|
212
|
-
// directly, so this is a no-op below) or the input stream ended on its own (piped/non-interactive
|
|
213
|
-
// stdin ran dry without the user ever typing exit/quit). Either way, defer the "are we actually
|
|
214
|
-
// done" check to the back of the queue rather than deciding right here - this can fire before an
|
|
215
|
-
// already-queued line (possibly the real exit/quit line) has had a chance to run, since a burst of
|
|
216
|
-
// buffered input can hit EOF in the same tick it delivers its last line.
|
|
217
|
-
queue = queue.then(() => {
|
|
218
|
-
if (!finished)
|
|
219
|
-
finish();
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
};
|
|
223
|
-
attach(createReplInterface(program, history));
|
|
224
|
-
// attach() assigns `current` synchronously before returning.
|
|
225
|
-
current.prompt();
|
|
226
|
-
});
|
|
227
|
-
// The history save was initiated in finish() but we waited for the REPL to resolve first. Now
|
|
228
|
-
// wait for the actual file write to complete before returning, so process.exit() (called by
|
|
229
|
-
// bin/botanary.ts immediately after await runCli() resolves) doesn't race the filesystem I/O.
|
|
230
|
-
await savePromise;
|
|
231
|
-
}
|
|
232
|
-
//# sourceMappingURL=repl.js.map
|
package/dist/src/repl.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repl.js","sourceRoot":"","sources":["../../src/repl.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,eAAe,CAAC;AAErC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,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,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QAC9C,6DAA6D;QAC7D,OAAQ,CAAC,MAAM,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,8FAA8F;IAC9F,4FAA4F;IAC5F,8FAA8F;IAC9F,MAAM,WAAW,CAAC;AACpB,CAAC"}
|
package/dist/src/review.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import * as clack from '@clack/prompts';
|
|
2
|
-
import { colors } from './render/colors.js';
|
|
3
|
-
import { kv, section } from './render/kv.js';
|
|
4
|
-
import { CliError, EXIT, invalidArgs } from './errors.js';
|
|
5
|
-
export function renderReview(title, rows, warnings) {
|
|
6
|
-
const blocks = [section(title), kv(rows.map((row) => [row.label, row.value]))];
|
|
7
|
-
if (warnings.length) {
|
|
8
|
-
blocks.push('');
|
|
9
|
-
for (const warning of warnings)
|
|
10
|
-
blocks.push(colors.warning(` ⚠ ${warning}`));
|
|
11
|
-
}
|
|
12
|
-
return blocks.join('\n');
|
|
13
|
-
}
|
|
14
|
-
/** The same panel, flat, for `--dry-run --json`. */
|
|
15
|
-
export function dryRunPayload(title, rows, warnings) {
|
|
16
|
-
return {
|
|
17
|
-
dryRun: true,
|
|
18
|
-
title,
|
|
19
|
-
review: Object.fromEntries(rows.map((row) => [row.label, row.value])),
|
|
20
|
-
warnings,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Show what is about to happen and get a yes, or refuse.
|
|
25
|
-
*
|
|
26
|
-
* 0.1.0 went from four free-text prompts straight to relaying funds. The gate has one hard rule: it never
|
|
27
|
-
* proceeds on an assumption. `--yes` is an explicit yes; an interactive terminal is asked; and anything
|
|
28
|
-
* else - a script, a pipe, `--json`, `--no-interactive` - is exit 2 naming the flag it needed, rather than
|
|
29
|
-
* a prompt that cannot render or a silent self-confirmation.
|
|
30
|
-
*/
|
|
31
|
-
export async function confirmOrThrow(ctx, title, rows, warnings, opts) {
|
|
32
|
-
// When yes came from the config file (confirm: never), still print the review panel so the user sees
|
|
33
|
-
// what is happening. When --yes was passed explicitly, skip the panel.
|
|
34
|
-
const yesFromConfig = ctx.yes && ctx.settings?.provenance?.yes === 'file';
|
|
35
|
-
if (yesFromConfig) {
|
|
36
|
-
if (!ctx.quiet)
|
|
37
|
-
console.log(renderReview(title, rows, warnings));
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (ctx.yes)
|
|
41
|
-
return;
|
|
42
|
-
if (ctx.json || !ctx.interactive) {
|
|
43
|
-
throw invalidArgs(`${opts?.because ?? 'This command moves funds and needs a confirmation it cannot ask for here.'} Pass --yes to confirm non-interactively, or --dry-run to preflight it instead.`);
|
|
44
|
-
}
|
|
45
|
-
if (!ctx.quiet)
|
|
46
|
-
console.log(renderReview(title, rows, warnings));
|
|
47
|
-
const answer = await clack.confirm({ message: opts?.question ?? 'Send it?', initialValue: false });
|
|
48
|
-
if (answer !== true) {
|
|
49
|
-
throw new CliError('Cancelled - nothing was signed and nothing was sent.', 'cancelled', EXIT.error);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=review.js.map
|
package/dist/src/review.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"review.js","sourceRoot":"","sources":["../../src/review.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAiB1D,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,IAAiB,EAAE,QAAkB;IAC/E,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,KAA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AC,GAAG;QAAE,OAAO;IACpB,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;QACjC,MAAM,WAAW,CACf,GAAG,IAAI,EAAE,OAAO,IAAI,2EAA2E,iFAAiF,CACjL,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,KAAK;QAAE,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;IACjE,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,IAAI,UAAU,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;IACnG,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,QAAQ,CAAC,sDAAsD,EAAE,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACtG,CAAC;AACH,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
|
-
/**
|
|
3
|
-
* Run a package manager and report its exit code.
|
|
4
|
-
*
|
|
5
|
-
* stdio is inherited (or partly silenced - see `RunInstallerOptions`) so npm's own progress, prompts and
|
|
6
|
-
* errors reach the user unfiltered - an installer failure explains itself far better than anything this
|
|
7
|
-
* CLI could re-author, and an EACCES on a global directory is exactly the kind of message that must not be
|
|
8
|
-
* swallowed.
|
|
9
|
-
*
|
|
10
|
-
* Never throws. A binary that is missing resolves non-zero like any other failure, because the caller
|
|
11
|
-
* does the same thing either way: report that nothing changed.
|
|
12
|
-
*/
|
|
13
|
-
export function runInstaller(command, options = {}) {
|
|
14
|
-
const [bin, ...args] = command;
|
|
15
|
-
if (!bin)
|
|
16
|
-
return Promise.resolve(1);
|
|
17
|
-
return new Promise((resolve) => {
|
|
18
|
-
const child = spawn(bin, args, {
|
|
19
|
-
stdio: options.silent ? ['ignore', 'ignore', 'inherit'] : 'inherit',
|
|
20
|
-
// npm, pnpm and yarn are `.cmd` shims on Windows. `spawn` does not apply PATHEXT, and since the fix
|
|
21
|
-
// for CVE-2024-27980 Node refuses to run a `.cmd` at all without `shell: true`. There is no
|
|
22
|
-
// injection surface here: `command` is always one of classifyInstall's constant-literal argv
|
|
23
|
-
// arrays, never user input.
|
|
24
|
-
shell: process.platform === 'win32',
|
|
25
|
-
});
|
|
26
|
-
child.on('error', () => resolve(1));
|
|
27
|
-
child.on('close', (code) => resolve(code ?? 1));
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=run-installer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-installer.js","sourceRoot":"","sources":["../../src/run-installer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAY3C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,OAAiB,EAAE,UAA+B,EAAE;IAC/E,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC;IAC/B,IAAI,CAAC,GAAG;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACpC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE;YAC7B,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS;YACnE,oGAAoG;YACpG,4FAA4F;YAC5F,6FAA6F;YAC7F,4BAA4B;YAC5B,KAAK,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO;SACpC,CAAC,CAAC;QACH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/src/settings.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import pc from 'picocolors';
|
|
2
|
-
import { invalidArgs } from './errors.js';
|
|
3
|
-
function truthy(value) {
|
|
4
|
-
return value === '1' || value === 'true' || value === 'yes';
|
|
5
|
-
}
|
|
6
|
-
/** One resolution order for everything: flag, then env, then the config file, then a built-in default. */
|
|
7
|
-
export function resolveSettings(input) {
|
|
8
|
-
const { opts, env, file, stdout, stdin } = input;
|
|
9
|
-
const provenance = {};
|
|
10
|
-
function pick(key, candidates, fallback) {
|
|
11
|
-
for (const [from, value] of candidates) {
|
|
12
|
-
if (value !== undefined) {
|
|
13
|
-
provenance[key] = from;
|
|
14
|
-
return value;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
provenance[key] = 'default';
|
|
18
|
-
return fallback;
|
|
19
|
-
}
|
|
20
|
-
const json = pick('json', [
|
|
21
|
-
['flag', opts.json === true ? true : undefined],
|
|
22
|
-
['env', truthy(env.BOTANARY_JSON) ? true : undefined],
|
|
23
|
-
['file', file.output === 'json' ? true : file.output === 'raw' ? false : undefined],
|
|
24
|
-
], !stdout.isTTY);
|
|
25
|
-
const rawRequested = pick('raw', [
|
|
26
|
-
['flag', opts.raw ? true : undefined],
|
|
27
|
-
['file', file.output === 'raw' ? true : undefined],
|
|
28
|
-
], false);
|
|
29
|
-
// `--json` wins, including the implicit one a pipe brings: `--raw` is a human affordance, and a machine
|
|
30
|
-
// consumer always gets the compact single-line form it can parse.
|
|
31
|
-
const raw = json ? false : rawRequested;
|
|
32
|
-
// When json overrides a requested raw, update provenance to match the actual value: the source was
|
|
33
|
-
// overridden, so reporting it would mislead a config list display.
|
|
34
|
-
if (json && rawRequested) {
|
|
35
|
-
provenance['raw'] = 'default';
|
|
36
|
-
}
|
|
37
|
-
const color = pick('color', [
|
|
38
|
-
['flag', opts.color === false ? false : undefined],
|
|
39
|
-
['env', env.NO_COLOR ? false : undefined],
|
|
40
|
-
['file', file.color === 'never' ? false : file.color === 'auto' ? pc.isColorSupported : undefined],
|
|
41
|
-
], pc.isColorSupported);
|
|
42
|
-
const interactive = pick('interactive', [['flag', opts.interactive === false ? false : undefined]], !!stdin.isTTY && !!stdout.isTTY);
|
|
43
|
-
const yes = pick('yes', [
|
|
44
|
-
['flag', opts.yes ? true : undefined],
|
|
45
|
-
['file', file.confirm === 'never' ? true : file.confirm === 'always' ? false : undefined],
|
|
46
|
-
], false);
|
|
47
|
-
const timeoutMs = pick('timeoutMs', [
|
|
48
|
-
['flag', opts.timeout === undefined ? undefined : parseTimeout(opts.timeout, '--timeout')],
|
|
49
|
-
['env', env.BOTANARY_TIMEOUT_MS === undefined ? undefined : parseTimeout(env.BOTANARY_TIMEOUT_MS, 'BOTANARY_TIMEOUT_MS')],
|
|
50
|
-
], null);
|
|
51
|
-
return {
|
|
52
|
-
json,
|
|
53
|
-
raw,
|
|
54
|
-
quiet: pick('quiet', [['flag', opts.quiet ? true : undefined]], false),
|
|
55
|
-
verbose: pick('verbose', [['flag', opts.verbose ? true : undefined]], false),
|
|
56
|
-
debug: pick('debug', [['flag', opts.debug ? true : undefined]], false),
|
|
57
|
-
color,
|
|
58
|
-
reveal: pick('reveal', [['flag', opts.reveal ? true : undefined]], false),
|
|
59
|
-
interactive,
|
|
60
|
-
yes,
|
|
61
|
-
dryRun: pick('dryRun', [['flag', opts.dryRun ? true : undefined]], false),
|
|
62
|
-
chain: pick('chain', [
|
|
63
|
-
['flag', opts.chain],
|
|
64
|
-
['env', env.BOTANARY_CHAIN_ID],
|
|
65
|
-
['file', file.chainId],
|
|
66
|
-
], null),
|
|
67
|
-
account: pick('account', [
|
|
68
|
-
['flag', opts.account],
|
|
69
|
-
['env', env.BOTANARY_ACCOUNT_ID],
|
|
70
|
-
['file', file.accountId],
|
|
71
|
-
], null),
|
|
72
|
-
apiUrl: pick('apiUrl', [
|
|
73
|
-
['flag', opts.apiUrl],
|
|
74
|
-
['env', env.BOTANARY_API_URL],
|
|
75
|
-
['file', file.apiUrl],
|
|
76
|
-
], null),
|
|
77
|
-
timeoutMs,
|
|
78
|
-
provenance,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function parseTimeout(value, source) {
|
|
82
|
-
const parsed = Number(value);
|
|
83
|
-
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
84
|
-
throw invalidArgs(`${source} must be a positive number of milliseconds, got "${value}".`);
|
|
85
|
-
}
|
|
86
|
-
return parsed;
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=settings.js.map
|