@alchemy/cli 0.1.5 → 0.2.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/README.md +59 -116
- package/dist/{chunk-F7KTEZFZ.js → chunk-MAKSV2EA.js} +1 -1
- package/dist/{chunk-PH4BPYSY.js → chunk-VD5WQHLQ.js} +1 -1
- package/dist/{chunk-QKXQW4OF.js → chunk-VRBWUQHA.js} +1 -0
- package/dist/index.js +199 -7
- package/dist/{interactive-2ITFWH3B.js → interactive-CP6E23OD.js} +3 -2
- package/dist/{onboarding-3J4EXZMG.js → onboarding-IKIXUTY7.js} +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,6 +18,58 @@ Or run without installing globally:
|
|
|
18
18
|
npx @alchemy/cli <command>
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
## Getting Started
|
|
22
|
+
|
|
23
|
+
### Authentication Quick Start
|
|
24
|
+
|
|
25
|
+
Authentication is required before making requests. Configure auth first, then run commands.
|
|
26
|
+
|
|
27
|
+
If you are using the CLI as a human in an interactive terminal, the easiest path is:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
alchemy
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Then follow the setup flow in the terminal UI to configure auth.
|
|
34
|
+
|
|
35
|
+
Know which auth method does what:
|
|
36
|
+
|
|
37
|
+
- **API key** - direct auth for blockchain queries (`balance`, `tx`, `block`, `nfts`, `tokens`, `rpc`)
|
|
38
|
+
- **Access key** - Admin/API app management; app setup/selection can also provide API key auth for blockchain queries
|
|
39
|
+
- **x402 wallet auth** - wallet-authenticated, pay-per-request model for supported blockchain queries
|
|
40
|
+
|
|
41
|
+
If you use Notify webhooks, add webhook auth on top via `alchemy config set webhook-api-key <key>`, `--webhook-api-key`, or `ALCHEMY_WEBHOOK_API_KEY`.
|
|
42
|
+
|
|
43
|
+
For setup commands, env vars, and resolution order, see [Authentication Reference](#authentication-reference).
|
|
44
|
+
|
|
45
|
+
### Usage By Workflow
|
|
46
|
+
|
|
47
|
+
After auth is configured, use the CLI differently depending on who is driving it:
|
|
48
|
+
|
|
49
|
+
- **Humans (interactive terminal):** start with `alchemy` and use the terminal UI/setup flow; this is the recommended path for human usage
|
|
50
|
+
- **Agents/scripts (automation):** always use `--json` and prefer non-interactive execution (`--no-interactive`)
|
|
51
|
+
|
|
52
|
+
Quick usage examples:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Human recommended entrypoint
|
|
56
|
+
alchemy
|
|
57
|
+
|
|
58
|
+
# Agent/script-friendly command
|
|
59
|
+
alchemy balance 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --json --no-interactive
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### Agent bootstrap
|
|
63
|
+
|
|
64
|
+
Have your agent run `agent-prompt` as its first step to get a complete, machine-readable contract describing every command, auth method, error code, and execution rule:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Agent runs this once to learn everything the CLI can do
|
|
68
|
+
alchemy --json agent-prompt
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
This returns a single JSON document with execution policy, preflight instructions, auth matrix, the full command tree with all arguments and options, error codes with recovery actions, and example invocations. No external docs required.
|
|
72
|
+
|
|
21
73
|
## Command Reference
|
|
22
74
|
|
|
23
75
|
Run commands as `alchemy <command>`.
|
|
@@ -103,6 +155,7 @@ Use `alchemy help` or `alchemy help <command>` for generated command help.
|
|
|
103
155
|
| `config get <key>` | Gets one config value | `alchemy config get network` |
|
|
104
156
|
| `config list` | Lists all config values | `alchemy config list` |
|
|
105
157
|
| `config reset [key]` | Resets one or all config values | `alchemy config reset --yes` |
|
|
158
|
+
| `agent-prompt` | Emits complete agent/automation usage instructions | `alchemy --json agent-prompt` |
|
|
106
159
|
| `version` | Prints CLI version | `alchemy version` |
|
|
107
160
|
|
|
108
161
|
## Flags
|
|
@@ -176,13 +229,13 @@ Additional env vars:
|
|
|
176
229
|
| `network list` | `--configured`, `--app-id <id>` |
|
|
177
230
|
| `config reset` | `-y, --yes` |
|
|
178
231
|
|
|
179
|
-
## Authentication
|
|
232
|
+
## Authentication Reference
|
|
180
233
|
|
|
181
234
|
The CLI supports three auth inputs:
|
|
182
235
|
|
|
183
236
|
- API key for blockchain queries (`balance`, `tx`, `block`, `nfts`, `tokens`, `rpc`)
|
|
184
|
-
- Access key for Admin API operations (`apps`, `chains`, configured network lookups)
|
|
185
|
-
- x402 wallet key for wallet-authenticated blockchain queries
|
|
237
|
+
- Access key for Admin API operations (`apps`, `chains`, configured network lookups`) and app setup/selection, which can also supply the API key used by blockchain query commands
|
|
238
|
+
- x402 wallet key for wallet-authenticated blockchain queries in a pay-per-request model
|
|
186
239
|
|
|
187
240
|
Notify/webhook commands use a webhook API key with resolution order:
|
|
188
241
|
`--webhook-api-key` -> `ALCHEMY_WEBHOOK_API_KEY` -> `ALCHEMY_NOTIFY_AUTH_TOKEN` -> config `webhook-api-key` -> configured app webhook key.
|
|
@@ -221,6 +274,9 @@ Resolution order: `--access-key` -> `ALCHEMY_ACCESS_KEY` -> config file.
|
|
|
221
274
|
|
|
222
275
|
#### x402 wallet auth
|
|
223
276
|
|
|
277
|
+
x402 is a wallet-authenticated, pay-per-request usage model for supported blockchain queries.
|
|
278
|
+
The CLI can generate or import the wallet key used for these requests.
|
|
279
|
+
|
|
224
280
|
```bash
|
|
225
281
|
# Generate/import a wallet managed by CLI
|
|
226
282
|
alchemy wallet generate
|
|
@@ -277,116 +333,3 @@ Errors are structured JSON in JSON mode:
|
|
|
277
333
|
}
|
|
278
334
|
}
|
|
279
335
|
```
|
|
280
|
-
|
|
281
|
-
## Development
|
|
282
|
-
|
|
283
|
-
Prerequisites:
|
|
284
|
-
|
|
285
|
-
- [Node.js 22+](https://nodejs.org/)
|
|
286
|
-
- [pnpm](https://pnpm.io/)
|
|
287
|
-
|
|
288
|
-
### Local development setup
|
|
289
|
-
|
|
290
|
-
```bash
|
|
291
|
-
git clone https://github.com/alchemyplatform/alchemy-cli.git
|
|
292
|
-
cd alchemy-cli
|
|
293
|
-
pnpm install
|
|
294
|
-
pnpm build
|
|
295
|
-
pnpm link --global
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
This makes the local `alchemy` build available globally for testing.
|
|
299
|
-
To unlink later: `pnpm unlink --global`.
|
|
300
|
-
|
|
301
|
-
Run during development:
|
|
302
|
-
|
|
303
|
-
```bash
|
|
304
|
-
# Run without building
|
|
305
|
-
npx tsx src/index.ts balance 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045
|
|
306
|
-
|
|
307
|
-
# Build in watch mode
|
|
308
|
-
pnpm dev
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
Build:
|
|
312
|
-
|
|
313
|
-
```bash
|
|
314
|
-
pnpm build
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
Test:
|
|
318
|
-
|
|
319
|
-
```bash
|
|
320
|
-
pnpm test
|
|
321
|
-
pnpm test:e2e
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
Type check:
|
|
325
|
-
|
|
326
|
-
```bash
|
|
327
|
-
pnpm lint
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
Coverage:
|
|
331
|
-
|
|
332
|
-
```bash
|
|
333
|
-
pnpm test:coverage
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
### Changesets & Releasing
|
|
337
|
-
|
|
338
|
-
This project uses [Changesets](https://github.com/changesets/changesets) for versioning and release notes.
|
|
339
|
-
|
|
340
|
-
**When to add a changeset:** Any PR with user-facing changes (new commands, bug fixes, flag changes, output format changes) needs a changeset. Internal changes (CI, refactors with no behavior change, docs) can skip by adding the `no-changeset` label.
|
|
341
|
-
|
|
342
|
-
**How to add a changeset:**
|
|
343
|
-
|
|
344
|
-
```bash
|
|
345
|
-
pnpm changeset
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
You'll be prompted to pick the bump type:
|
|
349
|
-
- **patch** — bug fixes, small tweaks (e.g. fixing `--json` output for a command)
|
|
350
|
-
- **minor** — new commands, new flags, new capabilities
|
|
351
|
-
- **major** — breaking changes (removed commands, changed flag behavior, output format changes)
|
|
352
|
-
|
|
353
|
-
This creates a file like `.changeset/cool-dogs-fly.md`:
|
|
354
|
-
|
|
355
|
-
```markdown
|
|
356
|
-
---
|
|
357
|
-
"@alchemy/cli": minor
|
|
358
|
-
---
|
|
359
|
-
|
|
360
|
-
Add `alchemy portfolio transactions` command for portfolio transaction history.
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
Write a 1-2 sentence summary of the change from a user's perspective. Commit this file with your PR.
|
|
364
|
-
|
|
365
|
-
**How releases work:** When PRs with changesets merge to `main`, the publish workflow automatically:
|
|
366
|
-
1. Verifies the build (typecheck, build, test)
|
|
367
|
-
2. Applies version bumps and updates `CHANGELOG.md` via `changeset version`
|
|
368
|
-
3. Creates a signed release commit via the GitHub Git Database API (using a GitHub App token)
|
|
369
|
-
4. Publishes to npm using OIDC trusted publishing (no long-lived npm token)
|
|
370
|
-
5. Creates a GitHub release/tag with notes extracted from `CHANGELOG.md`
|
|
371
|
-
|
|
372
|
-
If no changesets are pending, the workflow exits cleanly — no release is created.
|
|
373
|
-
|
|
374
|
-
**Release infrastructure:**
|
|
375
|
-
- Repository write operations use a GitHub App (`APP_ID` variable + `APP_PRIVATE_KEY` secret)
|
|
376
|
-
- npm publish uses [trusted publishing](https://docs.npmjs.com/generating-provenance-statements) (OIDC) — no `NPM_TOKEN` secret required
|
|
377
|
-
- Required GitHub repo settings: `APP_ID` (variable), `APP_PRIVATE_KEY` (secret)
|
|
378
|
-
- Required npm-side: configure trusted publishing for this repo/workflow at npmjs.com package settings
|
|
379
|
-
|
|
380
|
-
### Endpoint Override Env Vars (Local Testing Only)
|
|
381
|
-
|
|
382
|
-
These are for local/mock testing, not normal production usage:
|
|
383
|
-
|
|
384
|
-
- `ALCHEMY_RPC_BASE_URL`
|
|
385
|
-
- `ALCHEMY_ADMIN_API_BASE_URL`
|
|
386
|
-
- `ALCHEMY_X402_BASE_URL`
|
|
387
|
-
|
|
388
|
-
Safety constraints:
|
|
389
|
-
|
|
390
|
-
- Only localhost targets are accepted (`localhost`, `127.0.0.1`, `::1`)
|
|
391
|
-
- Non-HTTPS transport is allowed only for localhost
|
|
392
|
-
- Production defaults are unchanged when unset
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
|
|
3
3
|
import {
|
|
4
4
|
isInteractiveAllowed
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-VRBWUQHA.js";
|
|
6
6
|
|
|
7
7
|
// src/lib/networks.ts
|
|
8
8
|
var TESTNET_TOKEN_RE = /(testnet|sepolia|holesky|hoodi|devnet|minato|amoy|fuji|saigon|cardona|aeneid|curtis|chiado|cassiopeia|blaze|ropsten|signet|mocha|fam|bepolia)$/i;
|
package/dist/index.js
CHANGED
|
@@ -14,14 +14,16 @@ import {
|
|
|
14
14
|
splitCommaList,
|
|
15
15
|
validateAddress,
|
|
16
16
|
validateTxHash
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-VD5WQHLQ.js";
|
|
18
18
|
import {
|
|
19
19
|
getRPCNetworks,
|
|
20
20
|
getSetupStatus,
|
|
21
21
|
isSetupComplete,
|
|
22
22
|
shouldRunOnboarding
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-MAKSV2EA.js";
|
|
24
24
|
import {
|
|
25
|
+
EXIT_CODES,
|
|
26
|
+
ErrorCode,
|
|
25
27
|
bold,
|
|
26
28
|
brand,
|
|
27
29
|
brandedHelp,
|
|
@@ -60,7 +62,7 @@ import {
|
|
|
60
62
|
verbose,
|
|
61
63
|
weiToEth,
|
|
62
64
|
withSpinner
|
|
63
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-VRBWUQHA.js";
|
|
64
66
|
|
|
65
67
|
// src/index.ts
|
|
66
68
|
import { Command, Help } from "commander";
|
|
@@ -1609,6 +1611,195 @@ function registerSolana(program2) {
|
|
|
1609
1611
|
});
|
|
1610
1612
|
}
|
|
1611
1613
|
|
|
1614
|
+
// src/commands/agent-prompt.ts
|
|
1615
|
+
var RETRYABLE_CODES = /* @__PURE__ */ new Set([
|
|
1616
|
+
ErrorCode.RATE_LIMITED,
|
|
1617
|
+
ErrorCode.NETWORK_ERROR
|
|
1618
|
+
]);
|
|
1619
|
+
var ERROR_RECOVERY = {
|
|
1620
|
+
AUTH_REQUIRED: "Set ALCHEMY_API_KEY env var or run: alchemy config set api-key <key>",
|
|
1621
|
+
INVALID_API_KEY: "Check your API key and set a valid one: alchemy config set api-key <key>",
|
|
1622
|
+
NETWORK_NOT_ENABLED: "Enable the target network for your app at dashboard.alchemy.com",
|
|
1623
|
+
INVALID_ACCESS_KEY: "Check your access key: https://dashboard.alchemy.com/",
|
|
1624
|
+
ACCESS_KEY_REQUIRED: "Set ALCHEMY_ACCESS_KEY env var or run: alchemy config set access-key <key>",
|
|
1625
|
+
APP_REQUIRED: "Select an app: alchemy config set app <app-id>",
|
|
1626
|
+
ADMIN_API_ERROR: "Check the error message for details; verify access key permissions",
|
|
1627
|
+
NETWORK_ERROR: "Check internet connection and retry",
|
|
1628
|
+
RPC_ERROR: "Check RPC method, params, and network; verify API key has access",
|
|
1629
|
+
INVALID_ARGS: "Check command usage via: alchemy --json help <command>",
|
|
1630
|
+
NOT_FOUND: "Verify the resource identifier (address, hash, id) is correct",
|
|
1631
|
+
RATE_LIMITED: "Wait and retry; consider upgrading your Alchemy plan",
|
|
1632
|
+
PAYMENT_REQUIRED: "Fund your x402 wallet or switch to API key auth",
|
|
1633
|
+
SETUP_REQUIRED: "Run preflight: alchemy --json setup status, then follow nextCommands",
|
|
1634
|
+
INTERNAL_ERROR: "Unexpected error; retry or report a bug"
|
|
1635
|
+
};
|
|
1636
|
+
function buildCommandSchema(cmd) {
|
|
1637
|
+
const schema = {
|
|
1638
|
+
name: cmd.name(),
|
|
1639
|
+
description: cmd.description()
|
|
1640
|
+
};
|
|
1641
|
+
const aliases = cmd.aliases();
|
|
1642
|
+
if (aliases.length > 0) {
|
|
1643
|
+
schema.aliases = aliases;
|
|
1644
|
+
}
|
|
1645
|
+
const args = cmd.registeredArguments;
|
|
1646
|
+
if (args.length > 0) {
|
|
1647
|
+
schema.arguments = args.map((a) => ({
|
|
1648
|
+
name: a.name(),
|
|
1649
|
+
description: a.description,
|
|
1650
|
+
required: a.required
|
|
1651
|
+
}));
|
|
1652
|
+
}
|
|
1653
|
+
const opts = cmd.options;
|
|
1654
|
+
if (opts.length > 0) {
|
|
1655
|
+
schema.options = opts.map((o) => ({
|
|
1656
|
+
flags: o.flags,
|
|
1657
|
+
description: o.description
|
|
1658
|
+
}));
|
|
1659
|
+
}
|
|
1660
|
+
const subs = cmd.commands;
|
|
1661
|
+
if (subs.length > 0) {
|
|
1662
|
+
schema.subcommands = subs.map(buildCommandSchema);
|
|
1663
|
+
}
|
|
1664
|
+
return schema;
|
|
1665
|
+
}
|
|
1666
|
+
function buildAgentPrompt(program2) {
|
|
1667
|
+
const errors = {};
|
|
1668
|
+
for (const [code, exitCode] of Object.entries(EXIT_CODES)) {
|
|
1669
|
+
errors[code] = {
|
|
1670
|
+
exitCode,
|
|
1671
|
+
retryable: RETRYABLE_CODES.has(code),
|
|
1672
|
+
recovery: ERROR_RECOVERY[code] ?? "Check error message"
|
|
1673
|
+
};
|
|
1674
|
+
}
|
|
1675
|
+
const commands = program2.commands.filter((cmd) => cmd.name() !== "agent-prompt").map(buildCommandSchema);
|
|
1676
|
+
return {
|
|
1677
|
+
executionPolicy: [
|
|
1678
|
+
"Always pass --json --no-interactive",
|
|
1679
|
+
"Parse stdout as JSON on exit code 0",
|
|
1680
|
+
"Parse stderr as JSON on nonzero exit code",
|
|
1681
|
+
"Never run bare 'alchemy' without --json --no-interactive"
|
|
1682
|
+
],
|
|
1683
|
+
preflight: {
|
|
1684
|
+
command: "alchemy --json setup status",
|
|
1685
|
+
description: "Check auth readiness before first command. If complete is false, follow nextCommands in the response to configure auth."
|
|
1686
|
+
},
|
|
1687
|
+
auth: [
|
|
1688
|
+
{
|
|
1689
|
+
method: "API key",
|
|
1690
|
+
envVar: "ALCHEMY_API_KEY",
|
|
1691
|
+
flag: "--api-key <key>",
|
|
1692
|
+
configKey: "api-key",
|
|
1693
|
+
commandFamilies: [
|
|
1694
|
+
"balance",
|
|
1695
|
+
"tx",
|
|
1696
|
+
"block",
|
|
1697
|
+
"rpc",
|
|
1698
|
+
"trace",
|
|
1699
|
+
"debug",
|
|
1700
|
+
"tokens",
|
|
1701
|
+
"nfts",
|
|
1702
|
+
"transfers",
|
|
1703
|
+
"prices",
|
|
1704
|
+
"portfolio",
|
|
1705
|
+
"simulate",
|
|
1706
|
+
"solana"
|
|
1707
|
+
]
|
|
1708
|
+
},
|
|
1709
|
+
{
|
|
1710
|
+
method: "Access key",
|
|
1711
|
+
envVar: "ALCHEMY_ACCESS_KEY",
|
|
1712
|
+
flag: "--access-key <key>",
|
|
1713
|
+
configKey: "access-key",
|
|
1714
|
+
commandFamilies: ["apps", "chains", "network list --configured"]
|
|
1715
|
+
},
|
|
1716
|
+
{
|
|
1717
|
+
method: "Webhook API key",
|
|
1718
|
+
envVar: "ALCHEMY_WEBHOOK_API_KEY",
|
|
1719
|
+
flag: "--webhook-api-key <key>",
|
|
1720
|
+
configKey: "webhook-api-key",
|
|
1721
|
+
commandFamilies: ["webhooks"]
|
|
1722
|
+
},
|
|
1723
|
+
{
|
|
1724
|
+
method: "x402 wallet",
|
|
1725
|
+
envVar: "ALCHEMY_WALLET_KEY",
|
|
1726
|
+
flag: "--x402 --wallet-key-file <path>",
|
|
1727
|
+
configKey: "x402",
|
|
1728
|
+
commandFamilies: [
|
|
1729
|
+
"balance",
|
|
1730
|
+
"tx",
|
|
1731
|
+
"block",
|
|
1732
|
+
"rpc",
|
|
1733
|
+
"trace",
|
|
1734
|
+
"debug",
|
|
1735
|
+
"tokens",
|
|
1736
|
+
"nfts",
|
|
1737
|
+
"transfers"
|
|
1738
|
+
]
|
|
1739
|
+
}
|
|
1740
|
+
],
|
|
1741
|
+
commands,
|
|
1742
|
+
errors,
|
|
1743
|
+
examples: [
|
|
1744
|
+
"alchemy --json --no-interactive setup status",
|
|
1745
|
+
"alchemy --json --no-interactive balance 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --api-key $ALCHEMY_API_KEY",
|
|
1746
|
+
"alchemy --json --no-interactive apps list --access-key $ALCHEMY_ACCESS_KEY",
|
|
1747
|
+
"alchemy --json --no-interactive rpc eth_blockNumber --api-key $ALCHEMY_API_KEY",
|
|
1748
|
+
"alchemy --json --no-interactive network list"
|
|
1749
|
+
],
|
|
1750
|
+
docs: "https://www.alchemy.com/docs"
|
|
1751
|
+
};
|
|
1752
|
+
}
|
|
1753
|
+
function formatAsSystemPrompt(payload) {
|
|
1754
|
+
const lines = [];
|
|
1755
|
+
lines.push("Alchemy CLI agent instructions");
|
|
1756
|
+
lines.push("==============================");
|
|
1757
|
+
lines.push("");
|
|
1758
|
+
lines.push("Execution policy:");
|
|
1759
|
+
for (const rule of payload.executionPolicy) {
|
|
1760
|
+
lines.push(` - ${rule}`);
|
|
1761
|
+
}
|
|
1762
|
+
lines.push("");
|
|
1763
|
+
lines.push("Preflight:");
|
|
1764
|
+
lines.push(` Command: ${payload.preflight.command}`);
|
|
1765
|
+
lines.push(` ${payload.preflight.description}`);
|
|
1766
|
+
lines.push("");
|
|
1767
|
+
lines.push("Auth methods:");
|
|
1768
|
+
for (const auth of payload.auth) {
|
|
1769
|
+
lines.push(` ${auth.method}:`);
|
|
1770
|
+
lines.push(` env: ${auth.envVar}`);
|
|
1771
|
+
lines.push(` flag: ${auth.flag}`);
|
|
1772
|
+
lines.push(` config: alchemy config set ${auth.configKey} <value>`);
|
|
1773
|
+
lines.push(` commands: ${auth.commandFamilies.join(", ")}`);
|
|
1774
|
+
}
|
|
1775
|
+
lines.push("");
|
|
1776
|
+
lines.push("Error codes:");
|
|
1777
|
+
for (const [code, entry] of Object.entries(payload.errors)) {
|
|
1778
|
+
const retry = entry.retryable ? " [retryable]" : "";
|
|
1779
|
+
lines.push(` ${code} (exit ${entry.exitCode})${retry}: ${entry.recovery}`);
|
|
1780
|
+
}
|
|
1781
|
+
lines.push("");
|
|
1782
|
+
lines.push("Examples:");
|
|
1783
|
+
for (const example of payload.examples) {
|
|
1784
|
+
lines.push(` ${example}`);
|
|
1785
|
+
}
|
|
1786
|
+
lines.push("");
|
|
1787
|
+
lines.push(`Docs: ${payload.docs}`);
|
|
1788
|
+
lines.push(" For RPC method signatures, parameters, and supported networks.");
|
|
1789
|
+
lines.push("");
|
|
1790
|
+
lines.push(
|
|
1791
|
+
"For full command tree, run: alchemy --json agent-prompt"
|
|
1792
|
+
);
|
|
1793
|
+
lines.push("");
|
|
1794
|
+
return lines.join("\n");
|
|
1795
|
+
}
|
|
1796
|
+
function registerAgentPrompt(program2) {
|
|
1797
|
+
program2.command("agent-prompt").description("Emit complete agent/automation usage instructions").action(() => {
|
|
1798
|
+
const payload = buildAgentPrompt(program2);
|
|
1799
|
+
printHuman(formatAsSystemPrompt(payload), payload);
|
|
1800
|
+
});
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1612
1803
|
// src/index.ts
|
|
1613
1804
|
var hBrand = noColor ? identity : (s) => `\x1B[38;2;54;63;249m${s}\x1B[39m`;
|
|
1614
1805
|
var hBold = esc("1");
|
|
@@ -1646,7 +1837,7 @@ var ROOT_COMMAND_PILLARS = [
|
|
|
1646
1837
|
},
|
|
1647
1838
|
{
|
|
1648
1839
|
label: "Admin",
|
|
1649
|
-
commands: ["apps", "config", "setup", "version", "help"]
|
|
1840
|
+
commands: ["apps", "config", "setup", "agent-prompt", "version", "help"]
|
|
1650
1841
|
}
|
|
1651
1842
|
];
|
|
1652
1843
|
function formatCommandSignature(sub) {
|
|
@@ -1683,7 +1874,7 @@ var findCommandByPath = (root, path) => {
|
|
|
1683
1874
|
};
|
|
1684
1875
|
program.name("alchemy").description(
|
|
1685
1876
|
"The Alchemy CLI lets you query blockchain data, call JSON-RPC methods, and manage your Alchemy configuration."
|
|
1686
|
-
).version("0.
|
|
1877
|
+
).version("0.2.0").option("--api-key <key>", "Alchemy API key (env: ALCHEMY_API_KEY)").option("--access-key <key>", "Alchemy access key (env: ALCHEMY_ACCESS_KEY)").option(
|
|
1687
1878
|
"-n, --network <network>",
|
|
1688
1879
|
"Target network (default: eth-mainnet) (env: ALCHEMY_NETWORK)"
|
|
1689
1880
|
).option("--x402", "Use x402 wallet-based gateway auth").option("--wallet-key-file <path>", "Path to wallet private key file for x402").option("--json", "Force JSON output").option("-q, --quiet", "Suppress non-essential output").option("-v, --verbose", "Enable verbose output").option("--no-color", "Disable color output").option("--reveal", "Show secrets in plain text (TTY only)").option("--timeout <ms>", "Request timeout in milliseconds", parseInt).option("--debug", "Enable debug diagnostics").option("--no-interactive", "Disable REPL and prompt-driven interactions").addHelpCommand(false).configureOutput({
|
|
@@ -1835,13 +2026,13 @@ ${styledLine}`;
|
|
|
1835
2026
|
}
|
|
1836
2027
|
if (isInteractiveAllowed(program)) {
|
|
1837
2028
|
if (shouldRunOnboarding(program, cfg)) {
|
|
1838
|
-
const { runOnboarding } = await import("./onboarding-
|
|
2029
|
+
const { runOnboarding } = await import("./onboarding-IKIXUTY7.js");
|
|
1839
2030
|
const completed = await runOnboarding(program);
|
|
1840
2031
|
if (!completed) {
|
|
1841
2032
|
return;
|
|
1842
2033
|
}
|
|
1843
2034
|
}
|
|
1844
|
-
const { startREPL } = await import("./interactive-
|
|
2035
|
+
const { startREPL } = await import("./interactive-CP6E23OD.js");
|
|
1845
2036
|
program.exitOverride();
|
|
1846
2037
|
program.configureOutput({
|
|
1847
2038
|
writeErr: () => {
|
|
@@ -1874,6 +2065,7 @@ registerApps(program);
|
|
|
1874
2065
|
registerSetup(program);
|
|
1875
2066
|
registerConfig(program);
|
|
1876
2067
|
registerSolana(program);
|
|
2068
|
+
registerAgentPrompt(program);
|
|
1877
2069
|
registerVersion(program);
|
|
1878
2070
|
program.command("help [command...]").description("display help for command").action((commandPath) => {
|
|
1879
2071
|
if (!commandPath || commandPath.length === 0) {
|
|
@@ -3,7 +3,7 @@ if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
|
|
|
3
3
|
import {
|
|
4
4
|
getRPCNetworkIds,
|
|
5
5
|
getSetupMethod
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-MAKSV2EA.js";
|
|
7
7
|
import {
|
|
8
8
|
bgRgb,
|
|
9
9
|
bold,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
rgb,
|
|
19
19
|
setBrandedHelpSuppressed,
|
|
20
20
|
setReplMode
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-VRBWUQHA.js";
|
|
22
22
|
|
|
23
23
|
// src/commands/interactive.ts
|
|
24
24
|
import * as readline from "readline";
|
|
@@ -100,6 +100,7 @@ var COMMAND_NAMES = [
|
|
|
100
100
|
"tokens metadata",
|
|
101
101
|
"tokens allowance",
|
|
102
102
|
"tx",
|
|
103
|
+
"agent-prompt",
|
|
103
104
|
"version",
|
|
104
105
|
"wallet",
|
|
105
106
|
"wallet generate",
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
generateAndPersistWallet,
|
|
6
6
|
importAndPersistWallet,
|
|
7
7
|
selectOrCreateApp
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VD5WQHLQ.js";
|
|
9
9
|
import {
|
|
10
10
|
bold,
|
|
11
11
|
brand,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
promptSelect,
|
|
19
19
|
promptText,
|
|
20
20
|
save
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-VRBWUQHA.js";
|
|
22
22
|
|
|
23
23
|
// src/commands/onboarding.ts
|
|
24
24
|
function printNextSteps(method) {
|