@kaleidorg/mind 0.0.1 → 0.1.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/engine.d.ts +9 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +18 -2
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/skills/bundle.d.ts +30 -0
- package/dist/skills/bundle.d.ts.map +1 -0
- package/dist/skills/bundle.js +24 -0
- package/dist/skills/bundle.js.map +1 -0
- package/dist/skills/loader.d.ts +33 -0
- package/dist/skills/loader.d.ts.map +1 -0
- package/dist/skills/loader.js +59 -0
- package/dist/skills/loader.js.map +1 -0
- package/dist/skills/reference-source.d.ts +18 -0
- package/dist/skills/reference-source.d.ts.map +1 -0
- package/dist/skills/reference-source.js +53 -0
- package/dist/skills/reference-source.js.map +1 -0
- package/dist/skills/registry.d.ts +41 -0
- package/dist/skills/registry.d.ts.map +1 -0
- package/dist/skills/registry.js +167 -0
- package/dist/skills/registry.js.map +1 -0
- package/dist/skills/types.d.ts +53 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +18 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/tools/l402.d.ts +47 -0
- package/dist/tools/l402.d.ts.map +1 -0
- package/dist/tools/l402.js +84 -0
- package/dist/tools/l402.js.map +1 -0
- package/package.json +9 -2
- package/scripts/bundle-skills.mjs +84 -0
- package/skills/README.md +74 -0
- package/skills/bitrefill/SKILL.md +66 -0
- package/skills/bitrefill/references/api.md +99 -0
- package/skills/bitrefill/references/browse.md +71 -0
- package/skills/bitrefill/references/capability-matrix.md +115 -0
- package/skills/bitrefill/references/cli-headless-auth.md +133 -0
- package/skills/bitrefill/references/cli.md +237 -0
- package/skills/bitrefill/references/host-openclaw.md +167 -0
- package/skills/bitrefill/references/mcp.md +150 -0
- package/skills/bitrefill/references/safeguards.md +138 -0
- package/skills/bitrefill/references/troubleshooting.md +182 -0
- package/skills/kaleido-trading/SKILL.md +31 -0
- package/skills/kaleido-wallet/SKILL.md +28 -0
- package/src/engine.test.ts +204 -0
- package/src/engine.ts +27 -2
- package/src/index.ts +17 -0
- package/src/skills/bundle.ts +42 -0
- package/src/skills/loader.ts +63 -0
- package/src/skills/reference-source.ts +60 -0
- package/src/skills/registry.ts +183 -0
- package/src/skills/skills.test.ts +191 -0
- package/src/skills/types.ts +55 -0
- package/src/tools/l402.test.ts +113 -0
- package/src/tools/l402.ts +122 -0
- package/dist/providers/qvac.d.ts +0 -89
- package/dist/providers/qvac.d.ts.map +0 -1
- package/dist/providers/qvac.js +0 -150
- package/dist/providers/qvac.js.map +0 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Path: Browse the Website
|
|
2
|
+
|
|
3
|
+
Use when: user wants to **explore** Bitrefill (compare prices, learn product types, check denominations, see country availability) AND your runtime has a **residential-IP browser**. Browse-only by default — for purchases prefer [mcp.md](mcp.md).
|
|
4
|
+
|
|
5
|
+
## Hard requirement: residential IP
|
|
6
|
+
|
|
7
|
+
`www.bitrefill.com` sits behind Cloudflare. **Datacenter egress = 403.** Do NOT use Firecrawl, raw `fetch`, `curl`, or any scraping API.
|
|
8
|
+
|
|
9
|
+
Viable runtimes:
|
|
10
|
+
|
|
11
|
+
- **ChatGPT Atlas** — built-in residential Chromium.
|
|
12
|
+
- **Cursor** — built-in browser tool runs from user's machine.
|
|
13
|
+
- **Claude Code / Desktop / Cowork + Claude-for-Chrome** extension drives local Chrome.
|
|
14
|
+
- **Any host + Playwright/Chrome MCP** running on user's machine.
|
|
15
|
+
- **OpenClaw Gateway on user's host** — `browser` tool uses host IP. (See [host-openclaw.md](host-openclaw.md).)
|
|
16
|
+
|
|
17
|
+
Not viable: ChatGPT web/Agent (OpenAI datacenter), Gemini consumer (Google datacenter), Jules (Google VM), any cloud sandbox without residential proxy.
|
|
18
|
+
|
|
19
|
+
## URL patterns
|
|
20
|
+
|
|
21
|
+
First path segment = **country** (Alpha-2 lowercase). Second = **language**.
|
|
22
|
+
|
|
23
|
+
- Gift cards listing: `https://www.bitrefill.com/{country}/{lang}/gift-cards/`
|
|
24
|
+
- Gift card category: `https://www.bitrefill.com/{country}/{lang}/gift-cards/{category-slug}/` (e.g. `/us/en/gift-cards/food/`)
|
|
25
|
+
- Gift card product: `https://www.bitrefill.com/{country}/{lang}/gift-cards/{product-slug}/`
|
|
26
|
+
- Direct search: `https://www.bitrefill.com/{country}/{lang}/gift-cards/?q={query}` (covers gift cards + top-ups + eSIMs; in-country prioritized)
|
|
27
|
+
- Mobile top-ups: `https://www.bitrefill.com/refill/`
|
|
28
|
+
- eSIMs (locale): `https://www.bitrefill.com/{country}/{lang}/esims/`
|
|
29
|
+
- eSIMs (browse all destinations): `https://www.bitrefill.com/esim/all-destinations`
|
|
30
|
+
- Single eSIM: `https://www.bitrefill.com/{country}/{lang}/esims/bitrefill-esim-{destination-slug}/` (e.g. `bitrefill-esim-japan`, `bitrefill-esim-global`)
|
|
31
|
+
- Auth (no locale prefix): `/login`, `/signup`
|
|
32
|
+
|
|
33
|
+
## Country in URL vs geolock
|
|
34
|
+
|
|
35
|
+
- **URL country** filters which inventory is **listed**.
|
|
36
|
+
- **Geolock** is enforced at **IP level** at checkout. A product may appear in listing but be unpurchasable if user's IP is outside allowed region.
|
|
37
|
+
|
|
38
|
+
Match URL country to recipient's country to surface usable cards.
|
|
39
|
+
|
|
40
|
+
## Listing filters & sort (gift cards)
|
|
41
|
+
|
|
42
|
+
Query params on any gift-card listing (`/{country}/{lang}/gift-cards/[category/]`):
|
|
43
|
+
|
|
44
|
+
- `redemptionMethod` — `online` | `instore`
|
|
45
|
+
- `minRating` — `2` | `3` | `4` | `5`
|
|
46
|
+
- `minRewards` — `1`–`10` (cashback %)
|
|
47
|
+
- `s` — sort: `2` = A–Z, `3` = recently added, `4` = cashback. Default = popularity.
|
|
48
|
+
|
|
49
|
+
Example: `https://www.bitrefill.com/us/en/gift-cards/food/?minRating=5&minRewards=4&redemptionMethod=instore`
|
|
50
|
+
|
|
51
|
+
## Categories (popular slugs)
|
|
52
|
+
|
|
53
|
+
`top-products`, `retail`, `apparel`, `electronics`, `food`, `restaurants`, `food-delivery`, `streaming`, `games`, `travel`, `flights`, `accommodation`, `entertainment`, `gasoline`, `vpn`, `multi-brand`, `digital-wallet`, `groceries`, `pharmacy`, `experiences`, `gifts`. Full list: <https://docs.bitrefill.com/docs/Products>.
|
|
54
|
+
|
|
55
|
+
## Suggested flow
|
|
56
|
+
|
|
57
|
+
1. Clarify product type (gift card / top-up / eSIM) + country (+ carrier for top-ups).
|
|
58
|
+
2. Send user to direct search URL or category path.
|
|
59
|
+
3. For top-ups: country → carrier → amount.
|
|
60
|
+
4. For eSIMs: destination → data + duration.
|
|
61
|
+
5. Remind user to check denomination matches recipient's needs and that geolock applies at checkout.
|
|
62
|
+
|
|
63
|
+
## Purchase from the browser?
|
|
64
|
+
|
|
65
|
+
Possible but slow and risky. Anti-bot may block agent on brand redemption sites. Prefer [mcp.md](mcp.md) or [cli.md](cli.md) for purchases. If browser checkout is the only option, follow [safeguards.md](safeguards.md) — confirm with user, log invoice ID, treat redemption code as cash.
|
|
66
|
+
|
|
67
|
+
## Source of truth
|
|
68
|
+
|
|
69
|
+
- <https://www.bitrefill.com>
|
|
70
|
+
- <https://help.bitrefill.com>
|
|
71
|
+
- <https://docs.bitrefill.com/docs/Products>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Capability Matrix
|
|
2
|
+
|
|
3
|
+
Per-host cheat sheet. Each entry = viable paths in priority order + one-line reason. Pick the first that fits, fall back as needed.
|
|
4
|
+
|
|
5
|
+
Legend:
|
|
6
|
+
|
|
7
|
+
- **MCP** → [mcp.md](mcp.md)
|
|
8
|
+
- **CLI** → [cli.md](cli.md) (≥ 0.3.0: `login`/`verify`, not API key)
|
|
9
|
+
- **API** → [api.md](api.md)
|
|
10
|
+
- **Browse** → [browse.md](browse.md) (residential IP required)
|
|
11
|
+
- **OpenClaw** → [host-openclaw.md](host-openclaw.md)
|
|
12
|
+
|
|
13
|
+
## Anthropic
|
|
14
|
+
|
|
15
|
+
### Claude.ai web — Free
|
|
16
|
+
|
|
17
|
+
- No MCP custom URLs (Pro+ only). No shell. No residential browser.
|
|
18
|
+
- **Path**: none viable for purchases. For browse: only if user installs Claude-for-Chrome extension → Browse.
|
|
19
|
+
- **Fallback**: send user `bitrefill.com` link.
|
|
20
|
+
|
|
21
|
+
### Claude.ai web — Pro / Max / Team / Enterprise / Cowork
|
|
22
|
+
|
|
23
|
+
- MCP custom URLs allowed. Cowork adds desktop shell.
|
|
24
|
+
- **Paths**: MCP first → Browse via Claude-for-Chrome ext.
|
|
25
|
+
- Cowork only: + CLI via desktop shell.
|
|
26
|
+
|
|
27
|
+
### Claude Desktop
|
|
28
|
+
|
|
29
|
+
- MCP first-class (stdio + remote). No native shell, no native FS, no native HTTP — wire via MCP servers.
|
|
30
|
+
- **Paths**: MCP first → CLI via stdio MCP wrapping `npx @bitrefill/cli` → Browse via Chrome ext or Computer Use.
|
|
31
|
+
|
|
32
|
+
### Claude Code (CLI)
|
|
33
|
+
|
|
34
|
+
- Most flexible. Full host shell, MCP, WebFetch, Chrome ext.
|
|
35
|
+
- **Paths**: MCP first → CLI second → API via WebFetch / curl → Browse via Chrome ext or browser-use skill.
|
|
36
|
+
- Tighten: sandbox allowlist `api.bitrefill.com`, `registry.npmjs.org`. Deny `~/.ssh`, `.env`.
|
|
37
|
+
|
|
38
|
+
## OpenAI
|
|
39
|
+
|
|
40
|
+
### ChatGPT web — Free
|
|
41
|
+
|
|
42
|
+
- No custom MCP, no shell, datacenter browser → Cloudflare 403.
|
|
43
|
+
- **Path**: none. Send user `bitrefill.com` link.
|
|
44
|
+
|
|
45
|
+
### ChatGPT web — Plus / Pro / Business / Enterprise / Edu
|
|
46
|
+
|
|
47
|
+
- Custom MCP via Apps & Connectors (Developer Mode for write tools). Code Interpreter has no network.
|
|
48
|
+
- **Path**: MCP only. Browser is OpenAI datacenter — **do NOT route to Browse** (Cloudflare).
|
|
49
|
+
|
|
50
|
+
### ChatGPT Desktop
|
|
51
|
+
|
|
52
|
+
- Same as ChatGPT web. "Work with Apps" can read IDE/terminal panes but not execute.
|
|
53
|
+
- **Path**: MCP only.
|
|
54
|
+
|
|
55
|
+
### ChatGPT Atlas
|
|
56
|
+
|
|
57
|
+
- Built-in Chromium with **residential IP** (user's network). Inherits account connectors. No shell.
|
|
58
|
+
- **Paths**: Browse first (its superpower) → MCP via account connectors.
|
|
59
|
+
|
|
60
|
+
### ChatGPT Agent (formerly Operator)
|
|
61
|
+
|
|
62
|
+
- Sandboxed Linux + code interpreter. Hosted browser uses **OpenAI datacenter IP**.
|
|
63
|
+
- **Paths**: MCP via account connectors → CLI inside sandbox shell → API via curl. **Do NOT route to Browse** (Cloudflare).
|
|
64
|
+
|
|
65
|
+
### OpenAI Codex CLI
|
|
66
|
+
|
|
67
|
+
- Full host shell (Seatbelt/Landlock sandboxable). MCP stdio + HTTP. Profiles in `config.toml`.
|
|
68
|
+
- **Paths**: MCP first → CLI second → API via curl. Browser via MCP only.
|
|
69
|
+
- Tighten: `--sandbox workspace-write --ask-for-approval on-request`. API key in profile, not committed config.
|
|
70
|
+
|
|
71
|
+
## Google
|
|
72
|
+
|
|
73
|
+
### Gemini consumer — Free
|
|
74
|
+
|
|
75
|
+
- No MCP. No shell. No residential browser.
|
|
76
|
+
- **Path**: none. Send user `bitrefill.com` link.
|
|
77
|
+
|
|
78
|
+
### Gemini consumer — AI Pro / Ultra (US)
|
|
79
|
+
|
|
80
|
+
- "Auto Browse" runs from Google IPs → likely Cloudflare-blocked on bitrefill.com.
|
|
81
|
+
- **Path**: try Auto Browse + bitrefill.com URL; if blocked, send user the link.
|
|
82
|
+
|
|
83
|
+
### Gemini CLI
|
|
84
|
+
|
|
85
|
+
- Full host shell (sandboxable: Seatbelt / Docker / gVisor). MCP stdio + SSE + streamable-http.
|
|
86
|
+
- **Paths**: MCP first → CLI second → API via `web_fetch` or curl. Browser via MCP (Chrome DevTools / Playwright).
|
|
87
|
+
|
|
88
|
+
### Jules (async coding agent)
|
|
89
|
+
|
|
90
|
+
- Ephemeral Ubuntu VM, Google IPs, no MCP exposed to user, no residential browser.
|
|
91
|
+
- **Paths**: CLI inside VM → API via curl. **Not interactive** — best for batch tasks. No purchases recommended.
|
|
92
|
+
|
|
93
|
+
## Other
|
|
94
|
+
|
|
95
|
+
### Cursor IDE
|
|
96
|
+
|
|
97
|
+
- Built-in browser tool, terminal tool, MCP (40-tool cap across servers). Cloud Agents in isolated VM.
|
|
98
|
+
- **Paths**: MCP first → CLI in terminal → API via shell or built-in browser → Browse via built-in browser.
|
|
99
|
+
- Tighten: keep `buy-products` out of `autoApprove` in `.cursor/mcp.json`.
|
|
100
|
+
|
|
101
|
+
### OpenCode (sst/opencode)
|
|
102
|
+
|
|
103
|
+
- Full host shell. MCP stdio + HTTP. Permission model per agent (`allow`/`ask`/`deny`).
|
|
104
|
+
- **Paths**: MCP first → CLI second → API via `webfetch` or shell. Browser via MCP.
|
|
105
|
+
|
|
106
|
+
### OpenClaw — superset host
|
|
107
|
+
|
|
108
|
+
- Agentskills.io loader. MCP via `openclaw mcp set`. Full host shell + FS. `browser` tool uses host IP. Mobile nodes (camera, canvas, voice). Cron. Multi-channel chat (Telegram, WhatsApp, Slack, Discord, iMessage, Signal, Matrix, Teams, etc.).
|
|
109
|
+
- **Paths**: read [host-openclaw.md](host-openclaw.md) **first**. **Guest CLI via `exec`** (preferred) → signed-in CLI (`balance`, cashback) → MCP → API → Browse.
|
|
110
|
+
- Default agent: **Pi** (Anthropic / OpenAI / Google compatible via API key).
|
|
111
|
+
- Unique scenarios: chat-channel purchase from phone, cron auto-renew top-ups, mobile camera OCR of receipts, multi-channel handoff.
|
|
112
|
+
|
|
113
|
+
## Quick decision
|
|
114
|
+
|
|
115
|
+
If user says "what host am I in?": run `command -v openclaw` and check `~/.openclaw/`. OpenClaw → guest CLI first. Else: MCP first (most hosts), fall back to CLI, then API.
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Headless CLI auth (agents)
|
|
2
|
+
|
|
3
|
+
Use when: agent must **sign up / sign in** without human at keyboard — unlock `balance`, cashback, order history.
|
|
4
|
+
|
|
5
|
+
**Guest checkout needs no inbox** — pass `--email` on `buy-products` and pay crypto. Fastest first try; see [cli.md](cli.md) § Guest checkout.
|
|
6
|
+
|
|
7
|
+
Use this doc when graduating guest → signed-in account with AgentMail or equivalent inbox.
|
|
8
|
+
|
|
9
|
+
Requires `@bitrefill/cli` ≥ 0.3.0. Agent-owned inbox via **AgentMail or equivalent** — any provider with programmatic receive (list messages, parse body).
|
|
10
|
+
|
|
11
|
+
## Why AgentMail or equivalent
|
|
12
|
+
|
|
13
|
+
Bitrefill `login` sends magic-link code to email. Agent needs inbox API or MCP to poll/read messages without human. [AgentMail](https://www.agentmail.to/) is the reference implementation below; equivalent = Gmail API, IMAP, Mailgun inbound, etc. if your runtime already has access.
|
|
14
|
+
|
|
15
|
+
## One-time inbox setup (AgentMail example)
|
|
16
|
+
|
|
17
|
+
Human verifies provider account once. Agent handles Bitrefill after. Substitute your equivalent provider's sign-up + list/receive commands.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install -g agentmail-cli
|
|
21
|
+
|
|
22
|
+
agentmail agent sign-up \
|
|
23
|
+
--human-email you@example.com \
|
|
24
|
+
--username bitrefill-agent
|
|
25
|
+
# → api_key, inbox_id (e.g. bitrefill-agent@agentmail.to)
|
|
26
|
+
|
|
27
|
+
export AGENTMAIL_API_KEY="am_..." # from sign-up response
|
|
28
|
+
|
|
29
|
+
agentmail agent verify --otp-code 123456 # human reads OTP from you@example.com
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Official refs: [quickstart](https://docs.agentmail.to/quickstart.md), [agent onboarding](https://docs.agentmail.to/agent-onboarding.md).
|
|
33
|
+
|
|
34
|
+
Optional (AgentMail): [AgentMail MCP](https://docs.agentmail.to/agent-onboarding.md) (`npx -y agentmail-mcp`) with `AGENTMAIL_API_KEY` — tools `list_threads`, `get_thread`, `get_message`. Equivalent providers: use their MCP/API instead.
|
|
35
|
+
|
|
36
|
+
## Bitrefill auth flow
|
|
37
|
+
|
|
38
|
+
Use agent inbox address as Bitrefill email (`inbox_id` from AgentMail or equivalent). Signup = login (same command).
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install -g @bitrefill/cli
|
|
42
|
+
|
|
43
|
+
bitrefill init --openclaw # optional
|
|
44
|
+
|
|
45
|
+
bitrefill login --email bitrefill-agent@agentmail.to
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Poll inbox for Bitrefill verification email. AgentMail ([official list command](https://docs.agentmail.to/messages)):
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
agentmail inboxes:messages list --inbox-id bitrefill-agent@agentmail.to
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Parse `extracted_text` or `text` from latest message for numeric code. Then:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
bitrefill verify --code 123456
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
If Bitrefill account has TOTP, add `--otp` ([1Password](#totp-via-1password) below).
|
|
61
|
+
|
|
62
|
+
Confirm:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
bitrefill whoami --json
|
|
66
|
+
# → { "identity": "registered", "email": "bitrefill-agent@agentmail.to", ... }
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Then run catalog/purchase commands per [cli.md](cli.md).
|
|
70
|
+
|
|
71
|
+
## End-to-end script sketch
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
INBOX="bitrefill-agent@agentmail.to"
|
|
75
|
+
|
|
76
|
+
bitrefill login --email "$INBOX"
|
|
77
|
+
sleep 5 # allow delivery
|
|
78
|
+
|
|
79
|
+
CODE=$(agentmail inboxes:messages list --inbox-id "$INBOX" \
|
|
80
|
+
| jq -r '.messages[0].extracted_text // .messages[0].text' \
|
|
81
|
+
| grep -oE '[0-9]{6,8}' | head -1)
|
|
82
|
+
|
|
83
|
+
bitrefill verify --code "$CODE"
|
|
84
|
+
bitrefill whoami --json
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Adjust regex/poll loop for your environment. Codes expire (~12–20 min server-side); on expiry re-run `login`.
|
|
88
|
+
|
|
89
|
+
## TOTP via 1Password
|
|
90
|
+
|
|
91
|
+
When Bitrefill account has authenticator enrolled, pass TOTP on verify.
|
|
92
|
+
|
|
93
|
+
Secret reference ([official `op read`](https://www.1password.dev/cli/reference/commands/read)):
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
bitrefill verify --code "$CODE" \
|
|
97
|
+
--otp "$(op read 'op://Vault/Bitrefill/one-time password?attribute=otp')"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Item flag ([official `op item get --otp`](https://developer.1password.com/llms-cli.txt)):
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
bitrefill verify --code "$CODE" --otp "$(op item get Bitrefill --otp)"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Requires 1Password desktop app integration or service account. See [Get started with 1Password CLI](https://www.1password.dev/cli/get-started).
|
|
107
|
+
|
|
108
|
+
## Safeguards
|
|
109
|
+
|
|
110
|
+
- Dedicated low-balance Bitrefill account tied to agent inbox — not human primary email.
|
|
111
|
+
- Agent inbox (AgentMail or equivalent) = auth surface; restrict who can read it.
|
|
112
|
+
- `bitrefill reset` + re-login to rotate after compromise.
|
|
113
|
+
- Never log magic-link codes or redemption codes to shared transcripts.
|
|
114
|
+
|
|
115
|
+
Spending policy → [safeguards.md](safeguards.md).
|
|
116
|
+
|
|
117
|
+
## Troubleshooting
|
|
118
|
+
|
|
119
|
+
| Symptom | Fix |
|
|
120
|
+
|---------|-----|
|
|
121
|
+
| `Access token is required for login/verify` | Run any CLI command first (MCP connect mints token), or `bitrefill reset` then retry |
|
|
122
|
+
| `No pending login` | Re-run `login --email` before `verify` |
|
|
123
|
+
| Code invalid / expired | Re-run `login --email`; poll inbox again |
|
|
124
|
+
| `browser_url` in login response | Passkey/WebAuthn — human opens URL, then retry |
|
|
125
|
+
| Inbox empty after login | Wait + re-list; check spam; confirm inbox address matches provider setup |
|
|
126
|
+
|
|
127
|
+
More CLI errors → [troubleshooting.md](troubleshooting.md).
|
|
128
|
+
|
|
129
|
+
## Source of truth
|
|
130
|
+
|
|
131
|
+
- AgentMail (reference): <https://docs.agentmail.to/quickstart.md>, <https://docs.agentmail.to/messages>
|
|
132
|
+
- Bitrefill CLI: <https://github.com/bitrefill/cli> (≥ 0.3.0)
|
|
133
|
+
- 1Password CLI: <https://www.1password.dev/cli/reference/commands/read>
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# Path: CLI
|
|
2
|
+
|
|
3
|
+
Use when: shell + `npm install` available, **host has no MCP client** (CLI talks to Bitrefill MCP under the hood). Runtimes: Claude Code, Codex CLI, Cursor terminal, Gemini CLI, OpenCode, OpenClaw, Jules (ephemeral VM), ChatGPT Agent (sandbox).
|
|
4
|
+
|
|
5
|
+
Requires **`@bitrefill/cli` ≥ 0.3.0**. Sandboxed shells must allowlist `registry.npmjs.org` and `api.bitrefill.com`.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @bitrefill/cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
From source: `git clone https://github.com/bitrefill/cli.git && cd cli && pnpm install && pnpm build && npm link`.
|
|
14
|
+
|
|
15
|
+
## Guest checkout (fastest first try)
|
|
16
|
+
|
|
17
|
+
**No `login` / `verify`.** Works while `whoami` shows `identity: unregistered`. Fastest path for autonomous agents to try Bitrefill — search, quote, create invoice, pay crypto or open payment link.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
bitrefill search-products --query "Amazon" --country IT
|
|
21
|
+
bitrefill get-product-details --product_id "amazon_it-italy"
|
|
22
|
+
|
|
23
|
+
bitrefill buy-products \
|
|
24
|
+
--cart_items '[{"product_id":"amazon_it-italy","package_id":"10"}]' \
|
|
25
|
+
--payment_method lightning \
|
|
26
|
+
--return_payment_link true \
|
|
27
|
+
--email "agent@example.com"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Response: `invoice_id`, `payment_link`, optional `x402_payment_url` / Lightning invoice. Poll `get-invoice-by-id --invoice_id <uuid>`. Receipt goes to `--email`. Invoice expires in ~30 minutes.
|
|
31
|
+
|
|
32
|
+
Guest payment methods: crypto (`lightning`, `usdc_base`, `bitcoin`, …) or `--return_payment_link true` (human/browser checkout, x402). **`balance` and `cashback` require a signed-in account** (below).
|
|
33
|
+
|
|
34
|
+
## Sign up / sign in (balance, cashback, order history)
|
|
35
|
+
|
|
36
|
+
After guest try, sign in when human wants **managed agent spending** or **rewards**:
|
|
37
|
+
|
|
38
|
+
| Signed-in benefit | Why |
|
|
39
|
+
|-------------------|-----|
|
|
40
|
+
| **`--payment_method balance`** | Instant pay from store credit human pre-funds — natural spending cap, no on-chain wait |
|
|
41
|
+
| **`--payment_method cashback`** | Pay from accumulated rewards balance (BTC) |
|
|
42
|
+
| **Cashback on purchases** | Eligible products earn rewards back to account |
|
|
43
|
+
| **`list-orders` / `list-invoices`** | Full order history + redemption codes in one place |
|
|
44
|
+
|
|
45
|
+
Same `login` for new + existing accounts. Headless inbox → [cli-headless-auth.md](cli-headless-auth.md).
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
bitrefill login --email you@example.com
|
|
49
|
+
bitrefill verify --code GGWK87DR # email magic-link code
|
|
50
|
+
bitrefill verify --code GGWK87DR --otp 122407 # + TOTP when account has 2FA
|
|
51
|
+
bitrefill whoami --json
|
|
52
|
+
|
|
53
|
+
# signed-in buy — instant from balance
|
|
54
|
+
bitrefill buy-products \
|
|
55
|
+
--cart_items '[{"product_id":"amazon_it-italy","package_id":"10"}]' \
|
|
56
|
+
--payment_method balance \
|
|
57
|
+
--email "you@example.com"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Verify gotchas** (from real agent sessions):
|
|
61
|
+
|
|
62
|
+
- Email code → `verify --code <value>`, **not** `login --code` (unknown option).
|
|
63
|
+
- `--otp` = **authenticator TOTP only** when account has 2FA — not the email code. Need both `--code` and `--otp` when enrolled.
|
|
64
|
+
- After sign-in, `login` disappears from `--help`; run `logout` first to switch accounts or sign up another email.
|
|
65
|
+
|
|
66
|
+
## Bootstrap (optional)
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
bitrefill init # optional OpenClaw wiring only
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`init` no longer stores API keys. OpenClaw only: merges MCP config + generates `~/.openclaw/skills/bitrefill/SKILL.md`.
|
|
73
|
+
|
|
74
|
+
## Auth
|
|
75
|
+
|
|
76
|
+
CLI 0.3.0: **guest checkout needs no sign-in.** Account auth = OAuth client_credentials (automatic on first MCP connect) + email magic-link. No `--api-key`, no `credentials.json`.
|
|
77
|
+
|
|
78
|
+
| Step | Command | Notes |
|
|
79
|
+
|------|---------|-------|
|
|
80
|
+
| Register client | any command (or `login`) | MCP connect mints `access_token`; stored in `~/.config/bitrefill-cli/<host>.v1.json` |
|
|
81
|
+
| Sign up or sign in | `login --email <addr>` | same command for new + existing accounts |
|
|
82
|
+
| Complete auth | `verify --code <code> [--otp <totp>]` | code from email; `--otp` when account has TOTP |
|
|
83
|
+
| Check session | `whoami [--json]` | `identity: registered` + `email` when signed in |
|
|
84
|
+
| Sign out | `logout` | revokes session; keeps `client_id` |
|
|
85
|
+
| Full reset | `reset` | clears all local state + revokes session |
|
|
86
|
+
|
|
87
|
+
**TOTP via 1Password** ([official `op read`](https://www.1password.dev/cli/reference/commands/read)):
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
bitrefill verify --code "$CODE" --otp "$(op read 'op://Vault/Bitrefill/one-time password?attribute=otp')"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Shorthand ([official `op item get --otp`](https://developer.1password.com/llms-cli.txt)):
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
bitrefill verify --code "$CODE" --otp "$(op item get Bitrefill --otp)"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Server may return `browser_url` for passkey/WebAuthn — open in browser, then retry.
|
|
100
|
+
|
|
101
|
+
**Developer API keys** (Personal REST / key-in-path MCP) are separate from CLI auth. See [mcp.md](mcp.md) and [api.md](api.md).
|
|
102
|
+
|
|
103
|
+
## Global flags
|
|
104
|
+
|
|
105
|
+
Place **before** the subcommand:
|
|
106
|
+
|
|
107
|
+
- **`--json`** — stdout is a single JSON value per run (TOON decoded to JSON); status/errors on **stderr**. Use with `jq`.
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
bitrefill --json search-products --query "Amazon" --per_page 1 | jq '.products[0].name'
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Agent discovery
|
|
114
|
+
|
|
115
|
+
`manifest` emits JSON schema for every built-in + MCP command:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
bitrefill manifest --json | jq '.commands[].name'
|
|
119
|
+
bitrefill manifest -o bitrefill-manifest.json
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`llm-context` embeds the same manifest in a fenced JSON block.
|
|
123
|
+
|
|
124
|
+
## `llm-context`
|
|
125
|
+
|
|
126
|
+
Regenerates Markdown from live MCP `tools/list` (params, JSON Schema, example invocations). Use for **CLAUDE.md**, Cursor rules, or **`.github/copilot-instructions.md`**. Connection line shows redacted MCP URL — safe to commit.
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
bitrefill llm-context -o BITREFILL-MCP.md
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## OpenClaw quick-bootstrap
|
|
133
|
+
|
|
134
|
+
Optional `bitrefill init --openclaw`: merges MCP stub into `~/.openclaw/openclaw.json` + emits skill SKILL.md. **Not required for guest CLI** — install CLI and run guest checkout directly via `exec`. OpenClaw prefers guest CLI first; see [host-openclaw.md](host-openclaw.md). Hardening → exec-approvals for `bitrefill buy-products`.
|
|
135
|
+
|
|
136
|
+
## Workflow
|
|
137
|
+
|
|
138
|
+
Subcommands discovered from remote MCP (`bitrefill --help` after connect). Core flow:
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
search-products → get-product-details → buy-products → get-invoice-by-id
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### 1. Search
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
bitrefill search-products --query "Netflix" --country US
|
|
148
|
+
bitrefill --json search-products --query "Netflix" --country US --per_page 5 | jq '.products'
|
|
149
|
+
bitrefill search-products --query "eSIM" --product_type esim --country IT
|
|
150
|
+
bitrefill search-products --query "*" --category games --country US
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
`--country` = uppercase Alpha-2. `--product_type` = `giftcard` or `esim` (singular). Discover categories: `--query "*"` returns a `categories` array with slugs.
|
|
154
|
+
|
|
155
|
+
### 2. Details
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
bitrefill get-product-details --product_id "steam-usa" --currency USDC
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Returns `packages` array. Each entry has `package_value` — that's the `package_id` for `buy-products`. Ignore the `<&>` compound key.
|
|
162
|
+
|
|
163
|
+
Three denomination types:
|
|
164
|
+
|
|
165
|
+
- **Numeric**: `5`, `50`, `200` (pass as number).
|
|
166
|
+
- **Duration**: `"1 Month"`, `"12 Months"` (exact, case-sensitive).
|
|
167
|
+
- **Named**: `"1GB, 7 Days"`, `"PUBG New State 300 NC"` (exact, case-sensitive).
|
|
168
|
+
|
|
169
|
+
Only values from `get-product-details` accepted. Arbitrary amounts rejected.
|
|
170
|
+
|
|
171
|
+
### 3. Buy
|
|
172
|
+
|
|
173
|
+
`--cart_items` = JSON **array**, even single item. Max 15 items. **`--email`** = receipt address (required for guest; optional when signed in).
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Guest — crypto + payment link (no login)
|
|
177
|
+
bitrefill buy-products \
|
|
178
|
+
--cart_items '[{"product_id":"amazon_it-italy","package_id":"10"}]' \
|
|
179
|
+
--payment_method lightning \
|
|
180
|
+
--return_payment_link true \
|
|
181
|
+
--email "agent@example.com"
|
|
182
|
+
|
|
183
|
+
# Signed-in — instant from store credit
|
|
184
|
+
bitrefill buy-products \
|
|
185
|
+
--cart_items '[{"product_id": "steam-usa", "package_id": 5}]' \
|
|
186
|
+
--payment_method balance \
|
|
187
|
+
--email "you@example.com"
|
|
188
|
+
|
|
189
|
+
# Signed-in — crypto via x402
|
|
190
|
+
bitrefill buy-products \
|
|
191
|
+
--cart_items '[{"product_id": "steam-usa", "package_id": 5}]' \
|
|
192
|
+
--payment_method usdc_base
|
|
193
|
+
|
|
194
|
+
# Duration package
|
|
195
|
+
bitrefill buy-products \
|
|
196
|
+
--cart_items '[{"product_id": "spotify-usa", "package_id": "1 Month"}]' \
|
|
197
|
+
--payment_method balance
|
|
198
|
+
|
|
199
|
+
# Named eSIM
|
|
200
|
+
bitrefill buy-products \
|
|
201
|
+
--cart_items '[{"product_id": "bitrefill-esim-europe", "package_id": "1GB, 7 Days"}]' \
|
|
202
|
+
--payment_method usdc_base
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Response: `invoice_id`, `payment_link`, `x402_payment_url`, `payment_info` (`address`, `paymentUri`, `altcoinPrice`).
|
|
206
|
+
|
|
207
|
+
### 4. Track / Redeem
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
bitrefill get-invoice-by-id --invoice_id "UUID" # works guest (save invoice_id from buy response)
|
|
211
|
+
bitrefill list-orders --include_redemption_info true # signed-in only
|
|
212
|
+
bitrefill get-order-by-id --order_id "ID" # signed-in only
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Invoices expire after 180 minutes. Expired = create new one.
|
|
216
|
+
|
|
217
|
+
## Critical gotchas
|
|
218
|
+
|
|
219
|
+
- `--cart_items` must be **array** `[...]`, not object `{...}`. Shell quoting matters: single quotes outside, double inside.
|
|
220
|
+
- Use `package_value` after `<&>`, not the compound key. WRONG `"steam-usa<&>5"`. RIGHT `5`.
|
|
221
|
+
- Named/duration `package_id` exact and case-sensitive. WRONG `"1GB"`. RIGHT `"1GB, 7 Days"`.
|
|
222
|
+
- Country code uppercase Alpha-2. WRONG `us`, `USA`, `"United States"`. RIGHT `US`.
|
|
223
|
+
- `login` / `verify` only when not signed in. After verify, `logout` before switching accounts.
|
|
224
|
+
- Guest: `--payment_method balance` / `cashback` fail — use crypto or sign in first.
|
|
225
|
+
- Signed-in + 2FA: `verify` needs **both** `--code` (email) and `--otp` (authenticator).
|
|
226
|
+
|
|
227
|
+
## Recommended payment methods (for agents)
|
|
228
|
+
|
|
229
|
+
**Guest (try first):** `lightning` or `usdc_base` + `x402_payment_url` → `--return_payment_link true` for human/browser pay.
|
|
230
|
+
|
|
231
|
+
**Signed-in (production):** `balance` (instant, human caps spend via store credit) → `cashback` (rewards balance) → `usdc_base` x402 → `lightning`. Full list: `bitrefill buy-products --help`.
|
|
232
|
+
|
|
233
|
+
## Source of truth
|
|
234
|
+
|
|
235
|
+
- <https://github.com/bitrefill/cli> — full command reference, options, flags
|
|
236
|
+
- <https://docs.bitrefill.com/docs/crypto-payments> — payment methods
|
|
237
|
+
- `bitrefill manifest --json` / `bitrefill llm-context` — live tool list + schemas
|