@clawcard/cli 2.1.3 → 2.1.5
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/package.json +1 -1
- package/skill/SKILL.md +13 -2
- package/src/commands/agent.js +25 -0
- package/src/commands/billing.js +1 -3
- package/src/commands/settings.js +110 -0
- package/src/config.js +12 -0
- package/src/index.js +21 -0
package/package.json
CHANGED
package/skill/SKILL.md
CHANGED
|
@@ -107,11 +107,22 @@ View activity log:
|
|
|
107
107
|
clawcard agent activity --json [--limit 50]
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
+
## Billing Address
|
|
111
|
+
|
|
112
|
+
Get the user's billing address for checkout forms:
|
|
113
|
+
```
|
|
114
|
+
clawcard agent billing-address --json
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Returns: name, line1, line2, city, state, zip, country.
|
|
118
|
+
Use these values to fill billing/address fields on checkout pages.
|
|
119
|
+
|
|
110
120
|
## Paying on Checkout Pages
|
|
111
121
|
|
|
112
122
|
When you reach a payment form:
|
|
113
|
-
1.
|
|
114
|
-
2.
|
|
123
|
+
1. Get billing info: `clawcard agent billing-address --json`
|
|
124
|
+
2. Fill all non-payment fields yourself (name, email, address, zip) using the billing address
|
|
125
|
+
3. Create a card if needed:
|
|
115
126
|
```
|
|
116
127
|
clawcard agent cards create --amount <cents> --type single_use --memo "desc" --json
|
|
117
128
|
```
|
package/src/commands/agent.js
CHANGED
|
@@ -237,6 +237,31 @@ export async function agentActivityCmd(options) {
|
|
|
237
237
|
console.log();
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
+
// ── Billing Address ──
|
|
241
|
+
export async function agentBillingAddressCmd(options) {
|
|
242
|
+
const { getBillingAddress } = await import("../config.js");
|
|
243
|
+
const address = getBillingAddress();
|
|
244
|
+
|
|
245
|
+
if (!address) {
|
|
246
|
+
const err = "No billing address set. Run: clawcard settings";
|
|
247
|
+
if (options.json) return output({ success: false, error: err }, true);
|
|
248
|
+
console.log(` ${err}`);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (options.json) return output(address, true);
|
|
253
|
+
|
|
254
|
+
console.log();
|
|
255
|
+
console.log(` Name: ${address.name}`);
|
|
256
|
+
console.log(` Address: ${address.line1}`);
|
|
257
|
+
if (address.line2) console.log(` ${address.line2}`);
|
|
258
|
+
console.log(` City: ${address.city}`);
|
|
259
|
+
console.log(` State: ${address.state}`);
|
|
260
|
+
console.log(` ZIP: ${address.zip}`);
|
|
261
|
+
console.log(` Country: ${address.country}`);
|
|
262
|
+
console.log();
|
|
263
|
+
}
|
|
264
|
+
|
|
240
265
|
// ── Pay (fill payment form via browser extension) ──
|
|
241
266
|
export async function agentPayCmd(options) {
|
|
242
267
|
const http = await import("http");
|
package/src/commands/billing.js
CHANGED
|
@@ -72,10 +72,8 @@ export async function billingTopupCommand() {
|
|
|
72
72
|
message: "How much would you like to add? (10% processing fee)",
|
|
73
73
|
options: [
|
|
74
74
|
{ value: 500, label: "$5.00", hint: "you pay $5.50" },
|
|
75
|
-
{ value:
|
|
76
|
-
{ value: 2500, label: "$25.00", hint: "you pay $27.50" },
|
|
75
|
+
{ value: 2000, label: "$20.00", hint: "you pay $22.00" },
|
|
77
76
|
{ value: 5000, label: "$50.00", hint: "you pay $55.00" },
|
|
78
|
-
{ value: 10000, label: "$100.00", hint: "you pay $110.00" },
|
|
79
77
|
],
|
|
80
78
|
});
|
|
81
79
|
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import * as p from "@clack/prompts";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { requireAuth } from "../auth-guard.js";
|
|
4
|
+
import { getBillingAddress, saveBillingAddress } from "../config.js";
|
|
5
|
+
|
|
6
|
+
const orange = chalk.hex("#FF6B35");
|
|
7
|
+
|
|
8
|
+
export async function settingsCommand() {
|
|
9
|
+
requireAuth();
|
|
10
|
+
|
|
11
|
+
const existing = getBillingAddress();
|
|
12
|
+
|
|
13
|
+
if (existing) {
|
|
14
|
+
p.note(
|
|
15
|
+
[
|
|
16
|
+
`Name: ${existing.name}`,
|
|
17
|
+
`Address: ${existing.line1}`,
|
|
18
|
+
existing.line2 && ` ${existing.line2}`,
|
|
19
|
+
`City: ${existing.city}`,
|
|
20
|
+
`State: ${existing.state}`,
|
|
21
|
+
`ZIP: ${existing.zip}`,
|
|
22
|
+
`Country: ${existing.country}`,
|
|
23
|
+
]
|
|
24
|
+
.filter(Boolean)
|
|
25
|
+
.join("\n"),
|
|
26
|
+
"Billing Address"
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const update = await p.confirm({
|
|
30
|
+
message: "Update billing address?",
|
|
31
|
+
});
|
|
32
|
+
if (p.isCancel(update) || !update) return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const name = await p.text({
|
|
36
|
+
message: "Cardholder name",
|
|
37
|
+
placeholder: "Jane Smith",
|
|
38
|
+
initialValue: existing?.name || "",
|
|
39
|
+
validate: (v) => {
|
|
40
|
+
if (!v?.trim()) return "Name is required";
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
if (p.isCancel(name)) return;
|
|
44
|
+
|
|
45
|
+
const line1 = await p.text({
|
|
46
|
+
message: "Address line 1",
|
|
47
|
+
placeholder: "123 Main St",
|
|
48
|
+
initialValue: existing?.line1 || "",
|
|
49
|
+
validate: (v) => {
|
|
50
|
+
if (!v?.trim()) return "Address is required";
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
if (p.isCancel(line1)) return;
|
|
54
|
+
|
|
55
|
+
const line2 = await p.text({
|
|
56
|
+
message: "Address line 2 (optional)",
|
|
57
|
+
placeholder: "Apt 4B",
|
|
58
|
+
initialValue: existing?.line2 || "",
|
|
59
|
+
});
|
|
60
|
+
if (p.isCancel(line2)) return;
|
|
61
|
+
|
|
62
|
+
const city = await p.text({
|
|
63
|
+
message: "City",
|
|
64
|
+
placeholder: "San Francisco",
|
|
65
|
+
initialValue: existing?.city || "",
|
|
66
|
+
validate: (v) => {
|
|
67
|
+
if (!v?.trim()) return "City is required";
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
if (p.isCancel(city)) return;
|
|
71
|
+
|
|
72
|
+
const state = await p.text({
|
|
73
|
+
message: "State",
|
|
74
|
+
placeholder: "CA",
|
|
75
|
+
initialValue: existing?.state || "",
|
|
76
|
+
validate: (v) => {
|
|
77
|
+
if (!v?.trim()) return "State is required";
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
if (p.isCancel(state)) return;
|
|
81
|
+
|
|
82
|
+
const zip = await p.text({
|
|
83
|
+
message: "ZIP code",
|
|
84
|
+
placeholder: "94105",
|
|
85
|
+
initialValue: existing?.zip || "",
|
|
86
|
+
validate: (v) => {
|
|
87
|
+
if (!v?.trim()) return "ZIP is required";
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
if (p.isCancel(zip)) return;
|
|
91
|
+
|
|
92
|
+
const country = await p.text({
|
|
93
|
+
message: "Country",
|
|
94
|
+
placeholder: "US",
|
|
95
|
+
initialValue: existing?.country || "US",
|
|
96
|
+
});
|
|
97
|
+
if (p.isCancel(country)) return;
|
|
98
|
+
|
|
99
|
+
saveBillingAddress({
|
|
100
|
+
name,
|
|
101
|
+
line1,
|
|
102
|
+
line2: line2 || "",
|
|
103
|
+
city,
|
|
104
|
+
state,
|
|
105
|
+
zip,
|
|
106
|
+
country: country || "US",
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
p.log.success("Billing address saved");
|
|
110
|
+
}
|
package/src/config.js
CHANGED
|
@@ -66,3 +66,15 @@ export function getSavedKey(agentId) {
|
|
|
66
66
|
const keys = getSavedKeys();
|
|
67
67
|
return keys[agentId]?.apiKey ?? null;
|
|
68
68
|
}
|
|
69
|
+
|
|
70
|
+
// ── Billing address ──
|
|
71
|
+
export function getBillingAddress() {
|
|
72
|
+
const config = getConfig();
|
|
73
|
+
return config?.billingAddress ?? null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function saveBillingAddress(address) {
|
|
77
|
+
const config = getConfig() || {};
|
|
78
|
+
config.billingAddress = address;
|
|
79
|
+
saveConfig(config);
|
|
80
|
+
}
|
package/src/index.js
CHANGED
|
@@ -268,6 +268,25 @@ agent
|
|
|
268
268
|
await agentPayCmd(options);
|
|
269
269
|
});
|
|
270
270
|
|
|
271
|
+
// Agent billing address
|
|
272
|
+
agent
|
|
273
|
+
.command("billing-address")
|
|
274
|
+
.description("Get billing address for checkout forms")
|
|
275
|
+
.option("--json", "Output as JSON")
|
|
276
|
+
.action(async (options) => {
|
|
277
|
+
const { agentBillingAddressCmd } = await import("./commands/agent.js");
|
|
278
|
+
await agentBillingAddressCmd(options);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// Settings
|
|
282
|
+
program
|
|
283
|
+
.command("settings")
|
|
284
|
+
.description("Manage billing address and preferences")
|
|
285
|
+
.action(async () => {
|
|
286
|
+
const { settingsCommand } = await import("./commands/settings.js");
|
|
287
|
+
await settingsCommand();
|
|
288
|
+
});
|
|
289
|
+
|
|
271
290
|
// Setup
|
|
272
291
|
program
|
|
273
292
|
.command("setup")
|
|
@@ -407,6 +426,7 @@ if (process.argv.length <= 2) {
|
|
|
407
426
|
: []),
|
|
408
427
|
{ value: "topup", label: "Top up my account", hint: "add balance (10% fee)" },
|
|
409
428
|
{ value: "referral", label: "Referral", hint: "share & earn $5" },
|
|
429
|
+
{ value: "settings", label: "Settings", hint: "billing address & preferences" },
|
|
410
430
|
{ value: "whoami", label: "Who am I?", hint: "show current account" },
|
|
411
431
|
{ value: "dashboard", label: "Open dashboard", hint: "open in browser" },
|
|
412
432
|
{ value: "logout", label: "Logout", hint: "clear session" },
|
|
@@ -433,6 +453,7 @@ if (process.argv.length <= 2) {
|
|
|
433
453
|
"agent-fund": () => import("./commands/keys.js").then((m) => m.agentFundCommand()),
|
|
434
454
|
"keys-create": () => import("./commands/keys.js").then((m) => m.keysCreateCommand()),
|
|
435
455
|
"topup": () => import("./commands/billing.js").then((m) => m.billingTopupCommand()),
|
|
456
|
+
"settings": () => import("./commands/settings.js").then((m) => m.settingsCommand()),
|
|
436
457
|
"dashboard": async () => { const { default: open } = await import("open"); await open("https://www.clawcard.sh/dashboard"); },
|
|
437
458
|
keys: () => import("./commands/keys.js").then((m) => m.keysCommand()),
|
|
438
459
|
setup: () => import("./commands/setup.js").then((m) => m.setupCommand()),
|