@clawcard/cli 0.1.3 → 1.0.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/bin/setup.mjs DELETED
@@ -1,207 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
4
- import { join } from "path";
5
- import { homedir } from "os";
6
-
7
- const OPENCLAW_DIR = join(homedir(), ".openclaw");
8
- const SKILLS_DIR = join(OPENCLAW_DIR, "skills", "clawcard");
9
- const SKILL_PATH = join(SKILLS_DIR, "SKILL.md");
10
-
11
- const DEFAULT_BASE_URL = "https://www.clawcard.sh";
12
-
13
- const SKILL_MD = `---
14
- name: clawcard
15
- description: Email, SMS, virtual cards, and credential vault for autonomous agents
16
- metadata: {"openclaw":{"primaryEnv":"CLAWCARD_API_KEY","emoji":"\\ud83d\\udd11"}}
17
- ---
18
-
19
- You have access to ClawCard — a platform that gives you a real email address, phone number, virtual debit cards, and an encrypted credential vault.
20
-
21
- **Authentication:** All requests use your API key as a Bearer token.
22
-
23
- ## Getting Started
24
-
25
- Base URL: $CLAWCARD_BASE_URL (default: https://www.clawcard.sh)
26
- Auth header: Authorization: Bearer $CLAWCARD_API_KEY
27
-
28
- **Step 1: Discover your identity.** Call GET /api/me first — it returns your keyId, email, phone, and budget. Use the keyId for all other endpoints.
29
-
30
- curl -H "Authorization: Bearer $CLAWCARD_API_KEY" $CLAWCARD_BASE_URL/api/me
31
-
32
- Response: { "keyId": "agt_...", "name": "...", "email": "...", "phone": "...", "spendLimitCents": ... }
33
-
34
- ## Endpoints
35
-
36
- Use the keyId from /api/me as KEY_ID in all endpoints below.
37
-
38
- ### Identity
39
-
40
- **Get full identity details:**
41
-
42
- curl -H "Authorization: Bearer $CLAWCARD_API_KEY" $CLAWCARD_BASE_URL/api/agents/KEY_ID
43
-
44
- ### Email
45
-
46
- **Read inbox:**
47
-
48
- curl -H "Authorization: Bearer $CLAWCARD_API_KEY" "$CLAWCARD_BASE_URL/api/agents/KEY_ID/emails?limit=20"
49
-
50
- **Send email:**
51
-
52
- curl -X POST -H "Authorization: Bearer $CLAWCARD_API_KEY" -H "Content-Type: application/json" \\
53
- -d '{"to":"recipient@example.com","subject":"Hello","body":"Message text"}' \\
54
- $CLAWCARD_BASE_URL/api/agents/KEY_ID/emails/send
55
-
56
- ### SMS (inbound only)
57
-
58
- Each key gets a dedicated phone number for receiving SMS (e.g. verification codes). Outbound SMS is not currently supported.
59
-
60
- **Read received messages:**
61
-
62
- curl -H "Authorization: Bearer $CLAWCARD_API_KEY" "$CLAWCARD_BASE_URL/api/agents/KEY_ID/sms?limit=20"
63
-
64
- ### Virtual Cards
65
-
66
- **List cards:**
67
-
68
- curl -H "Authorization: Bearer $CLAWCARD_API_KEY" $CLAWCARD_BASE_URL/api/agents/KEY_ID/cards
69
-
70
- **Create a card (returns PAN, CVV, expiry):**
71
-
72
- curl -X POST -H "Authorization: Bearer $CLAWCARD_API_KEY" -H "Content-Type: application/json" \\
73
- -d '{"amountCents":1000,"memo":"Hosting payment","type":"single_use"}' \\
74
- $CLAWCARD_BASE_URL/api/agents/KEY_ID/cards
75
-
76
- Card types:
77
- - single_use — card closes automatically after one successful transaction. Best for one-time purchases.
78
- - merchant_locked — card locks to the first merchant that charges it. Best for subscriptions or repeated payments to the same service (e.g. hosting, SaaS).
79
-
80
- **Get card details (PAN, CVV):**
81
-
82
- curl -H "Authorization: Bearer $CLAWCARD_API_KEY" $CLAWCARD_BASE_URL/api/agents/KEY_ID/cards/CARD_ID
83
-
84
- **Close a card:**
85
-
86
- curl -X PATCH -H "Authorization: Bearer $CLAWCARD_API_KEY" -H "Content-Type: application/json" \\
87
- -d '{"action":"close"}' \\
88
- $CLAWCARD_BASE_URL/api/agents/KEY_ID/cards/CARD_ID
89
-
90
- ### Credentials Vault
91
-
92
- **Store a credential:**
93
-
94
- curl -X POST -H "Authorization: Bearer $CLAWCARD_API_KEY" -H "Content-Type: application/json" \\
95
- -d '{"service":"aws","key":"access_key","value":"AKIA..."}' \\
96
- $CLAWCARD_BASE_URL/api/agents/KEY_ID/credentials
97
-
98
- **Retrieve a credential:**
99
-
100
- curl -H "Authorization: Bearer $CLAWCARD_API_KEY" $CLAWCARD_BASE_URL/api/agents/KEY_ID/credentials/SERVICE/KEY
101
-
102
- ### Budget
103
-
104
- **Check remaining budget:**
105
-
106
- curl -H "Authorization: Bearer $CLAWCARD_API_KEY" $CLAWCARD_BASE_URL/api/agents/KEY_ID/budget
107
-
108
- **Allocate budget (moves funds from account balance to this key):**
109
-
110
- curl -X POST -H "Authorization: Bearer $CLAWCARD_API_KEY" -H "Content-Type: application/json" \\
111
- -d '{"amountCents":1000}' \\
112
- $CLAWCARD_BASE_URL/api/agents/KEY_ID/budget
113
- `;
114
-
115
- // ── Helpers ──────────────────────────────────────────────────────
116
-
117
- function log(msg) {
118
- console.log(` ${msg}`);
119
- }
120
-
121
- function success(msg) {
122
- console.log(` \x1b[32m✓\x1b[0m ${msg}`);
123
- }
124
-
125
- function warn(msg) {
126
- console.log(` \x1b[33m!\x1b[0m ${msg}`);
127
- }
128
-
129
- function error(msg) {
130
- console.error(` \x1b[31m✗\x1b[0m ${msg}`);
131
- }
132
-
133
- // ── Main ─────────────────────────────────────────────────────────
134
-
135
- const args = process.argv.slice(2);
136
- const apiKey = args[0];
137
- const baseUrl = args[1] || DEFAULT_BASE_URL;
138
-
139
- console.log();
140
- console.log(" \x1b[1m🦞 ClawCard Setup\x1b[0m");
141
- console.log();
142
-
143
- if (!apiKey || apiKey.startsWith("-")) {
144
- log("Usage: npx clawcard <API_KEY> [BASE_URL]");
145
- log("");
146
- log("Example:");
147
- log(" npx clawcard ak_live_abc123...");
148
- log(" npx clawcard ak_live_abc123... http://localhost:3000");
149
- console.log();
150
- process.exit(1);
151
- }
152
-
153
- if (!apiKey.startsWith("ak_live_")) {
154
- warn("API key doesn't start with 'ak_live_' — are you sure this is correct?");
155
- }
156
-
157
- // Check OpenClaw is installed
158
- if (!existsSync(OPENCLAW_DIR)) {
159
- error("OpenClaw directory not found at ~/.openclaw");
160
- log("Install OpenClaw first: https://openclaw.dev");
161
- console.log();
162
- process.exit(1);
163
- }
164
-
165
- // 1. Write skill file
166
- mkdirSync(SKILLS_DIR, { recursive: true });
167
- writeFileSync(SKILL_PATH, SKILL_MD);
168
- success(`Skill written to ${SKILL_PATH}`);
169
-
170
- // 2. Write env vars to ~/.openclaw/.env
171
- const ENV_PATH = join(OPENCLAW_DIR, ".env");
172
- let envContent = "";
173
- try {
174
- envContent = readFileSync(ENV_PATH, "utf-8");
175
- } catch {
176
- // .env doesn't exist yet, that's fine
177
- }
178
-
179
- // Update or append each var
180
- const envVars = {
181
- CLAWCARD_API_KEY: apiKey,
182
- CLAWCARD_BASE_URL: baseUrl,
183
- };
184
-
185
- for (const [key, value] of Object.entries(envVars)) {
186
- const regex = new RegExp(`^${key}=.*$`, "m");
187
- if (regex.test(envContent)) {
188
- envContent = envContent.replace(regex, `${key}=${value}`);
189
- } else {
190
- envContent = envContent.trimEnd() + `\n${key}=${value}\n`;
191
- }
192
- }
193
-
194
- writeFileSync(ENV_PATH, envContent);
195
- success(`Credentials written to ${ENV_PATH}`);
196
-
197
- // 3. Done
198
- console.log();
199
- log("\x1b[1mSetup complete!\x1b[0m Your agent now has access to:");
200
- log(" 📧 Email inbox");
201
- log(" 📱 Phone number & SMS");
202
- log(" 💳 Virtual debit cards");
203
- log(" 🔐 Encrypted credential vault");
204
- console.log();
205
- log("Tell your agent to \x1b[1m\"refresh skills\"\x1b[0m or restart the gateway.");
206
- log("Then try: \x1b[36m\"Use ClawCard to check your identity\"\x1b[0m");
207
- console.log();