feat(sdk): add ampersend CLI for x402 HTTP requests#55
feat(sdk): add ampersend CLI for x402 HTTP requests#55matiasedgeandnode wants to merge 8 commits intomainfrom
Conversation
6063043 to
005dd4b
Compare
c2b9b23 to
8970ab9
Compare
Add a curl-like CLI tool for making HTTP requests to x402 payment-gated APIs. Designed for agent use with structured JSON output. - Automatic 402 handling with Ampersend smart account payments - JSON envelope output with ok/error discrimination - --inspect mode to preview payment requirements without paying - --raw mode for human-readable output - --headers and --debug flags for troubleshooting - OpenClaw skill definition for agent integration Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
8970ab9 to
dad5003
Compare
- Extract shared JSON envelope types to envelope.ts to eliminate
duplication between fetch.ts and config.ts
- Standardize error format: all errors now use {code, message} structure
instead of allowing plain strings
- Use viem's isAddress() for proper Ethereum address validation
- Hardcode VERSION constant instead of runtime package.json read
- Remove --debug flag and debug.ts (350 lines) - will revisit later
- Add tests for envelope and config modules
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
f6e92e0 to
78eca8d
Compare
skills/ampersend/SKILL.md
Outdated
|
|
||
| ```bash | ||
| ampersend config init | ||
| # {"ok": true, "data": {"sessionKeyAddress": "0x...", "status": "pending_agent"}} |
There was a problem hiding this comment.
let's not call it sessionKeyAddress, maybe agentKeyAddress?
There was a problem hiding this comment.
yes working on a global renaming. Will end up having:
agentKeyAddressagentKeyagentAccountagentSecret
There was a problem hiding this comment.
nice! I wonder if it'd be good to have a note in the skill.md briefly explaining what these are and which are relevant or irrelevant for the user?
There was a problem hiding this comment.
How about we do something like:
Human-readable identifier for agent configurations, replacing long hex addresses with memorable word combinations like brave-tiger-sunset.
How it works:
- SHA256 hash of {agent_key_address}:{agent_account} (both lowercase)
- First 32 bits map to 3 words from BIP39 word list (2048 curated words)
- Deterministic: same inputs → same name on both CLI and platform
Why:
- Users can visually verify their agent matches across CLI and dashboard
- Memorable enough to recognize ("is this my agent?")
- ~1 billion combinations—sufficient uniqueness for practical use
Example:
0xABC...123 + 0xDEF...456 → "brave-tiger-sunset"
And then we can start surfacing this identifier (maybe call it config-name or similar) both in the CLI and in the UI?
There was a problem hiding this comment.
ok, for now I've added a simple configName to be surfaced everywhere. Will move to full human-readable implementation in a future PR.
| npm install -g @ampersend_ai/ampersend-sdk | ||
| ``` | ||
|
|
||
| If not configured, commands return setup instructions. To configure: |
There was a problem hiding this comment.
I think a short explanation of what this does would be useful. What does config init actually do? What does it mean to register the key in the dashboard?
There was a problem hiding this comment.
I'd rather wait until the agent lead onboarding is out and then clean this up. Init is pretty useless at this point for an agent, can't do much about it. Because in fact the dashboard doesn't allow to add an arbitrary key to an agent.
skills/ampersend/SKILL.md
Outdated
|
|
||
| # Ampersend CLI | ||
|
|
||
| CLI for Ampersend smart account wallets. Enables agents to make payments. |
There was a problem hiding this comment.
A bit more information about ampersend would be useful, so that an agent reading this can explain to the human what makes ampersend an interesting way to enable payments
There was a problem hiding this comment.
I'd also suggest adding something like:
## Security
NEVER ask the user to sign in to the ampersend dashboard in a browser to which you have access. If you need changes in the ampersend configuration, ask your user to do them.
(eventually we'll show how to request changes, etc, but for now I think this is the main thing we wanna ensure)
There was a problem hiding this comment.
I've added some version of this, but would rather refine the SKILL.md in subsequent PRs.
Summary
ampersend fetchcommand - a curl-like CLI for making HTTP requests to x402 payment-gated APIs with automatic payment handlingampersend configcommands for managing smart account configuration (init,set-agent,status,set-api,clear-api)Test plan
pnpm buildto verify TypeScript compilespnpm testto verify existing tests passampersend config initcreates config with session keyampersend config set-agent <address>completes setupampersend config statusshows correct stateampersend fetch --inspect <url>shows payment requirements without payingampersend fetch <url>makes request with automatic payment--raw,--headers, and--debugflags work correctlyAMPERSEND_AGENT_KEY) takes precedence over file configGenerated with Claude Code