@clawcard/cli 1.1.2 → 1.1.4
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/src/commands/signup.js +36 -16
- package/src/index.js +56 -27
package/package.json
CHANGED
package/src/commands/signup.js
CHANGED
|
@@ -45,33 +45,53 @@ export async function signupCommand() {
|
|
|
45
45
|
|
|
46
46
|
p.note(
|
|
47
47
|
[
|
|
48
|
-
`${orange.bold("Step 1:")}
|
|
49
|
-
` ${chalk.dim("$
|
|
48
|
+
`${orange.bold("Step 1:")} Top up your balance`,
|
|
49
|
+
` ${chalk.dim("Minimum $5 to get started")}`,
|
|
50
50
|
"",
|
|
51
|
-
`${orange.bold("Step 2:")}
|
|
52
|
-
` ${chalk.dim("
|
|
51
|
+
`${orange.bold("Step 2:")} Create your agent key`,
|
|
52
|
+
` ${chalk.dim("Gets you an email, phone number, and virtual cards")}`,
|
|
53
53
|
"",
|
|
54
|
-
`${orange.bold("Step 3:")}
|
|
55
|
-
` ${chalk.dim("
|
|
54
|
+
`${orange.bold("Step 3:")} Set up your agent`,
|
|
55
|
+
` ${chalk.dim("Installs the ClawCard skill for your agent")}`,
|
|
56
56
|
].join("\n"),
|
|
57
57
|
"Getting Started"
|
|
58
58
|
);
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
// Step 1: Top up
|
|
61
|
+
const topup = await p.confirm({
|
|
62
|
+
message: "Top up your balance now? (required to create an agent)",
|
|
62
63
|
});
|
|
63
64
|
|
|
64
|
-
if (!p.isCancel(
|
|
65
|
-
const {
|
|
66
|
-
await
|
|
65
|
+
if (!p.isCancel(topup) && topup) {
|
|
66
|
+
const { billingTopupCommand } = await import("./billing.js");
|
|
67
|
+
await billingTopupCommand();
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
p.log.info(chalk.dim("Complete the payment in your browser, then come back here."));
|
|
70
|
+
|
|
71
|
+
const ready = await p.confirm({
|
|
72
|
+
message: "Payment complete?",
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
if (p.isCancel(ready) || !ready) return;
|
|
76
|
+
|
|
77
|
+
// Step 2: Create key
|
|
78
|
+
const createKey = await p.confirm({
|
|
79
|
+
message: "Create your agent key now?",
|
|
70
80
|
});
|
|
71
81
|
|
|
72
|
-
if (!p.isCancel(
|
|
73
|
-
const {
|
|
74
|
-
await
|
|
82
|
+
if (!p.isCancel(createKey) && createKey) {
|
|
83
|
+
const { keysCreateCommand } = await import("./keys.js");
|
|
84
|
+
await keysCreateCommand();
|
|
85
|
+
|
|
86
|
+
// Step 3: Setup
|
|
87
|
+
const runSetup = await p.confirm({
|
|
88
|
+
message: "Set up your agent now?",
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
if (!p.isCancel(runSetup) && runSetup) {
|
|
92
|
+
const { setupCommand } = await import("./setup.js");
|
|
93
|
+
await setupCommand();
|
|
94
|
+
}
|
|
75
95
|
}
|
|
76
96
|
}
|
|
77
97
|
} catch (err) {
|
package/src/index.js
CHANGED
|
@@ -186,33 +186,61 @@ if (process.argv.length <= 2) {
|
|
|
186
186
|
);
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
{
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
189
|
+
let options;
|
|
190
|
+
|
|
191
|
+
if (!loggedIn) {
|
|
192
|
+
options = [
|
|
193
|
+
{ value: "login", label: "Log in", hint: "authenticate via browser" },
|
|
194
|
+
{
|
|
195
|
+
value: "signup",
|
|
196
|
+
label: "Sign up",
|
|
197
|
+
hint: "create account with invite code",
|
|
198
|
+
},
|
|
199
|
+
{ value: "help", label: "Help", hint: "show all commands" },
|
|
200
|
+
];
|
|
201
|
+
} else {
|
|
202
|
+
// Check user state to show contextual nudges
|
|
203
|
+
let hasBalance = true;
|
|
204
|
+
let hasAgent = true;
|
|
205
|
+
|
|
206
|
+
try {
|
|
207
|
+
const { getBalance, listAgents } = await import("./api.js");
|
|
208
|
+
const [balance, agents] = await Promise.all([
|
|
209
|
+
getBalance().catch(() => ({ amountCents: 0 })),
|
|
210
|
+
listAgents().catch(() => []),
|
|
211
|
+
]);
|
|
212
|
+
hasBalance = balance.amountCents >= 500;
|
|
213
|
+
hasAgent = agents.some((a) => a.status === "active");
|
|
214
|
+
} catch {
|
|
215
|
+
// couldn't check — show full menu
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (!hasBalance) {
|
|
219
|
+
p.log.warn(
|
|
220
|
+
`You need at least $5 balance to create an agent. Run ${orange("clawcard billing topup")} to get started.`
|
|
221
|
+
);
|
|
222
|
+
} else if (!hasAgent) {
|
|
223
|
+
p.log.warn(
|
|
224
|
+
`You have balance but no agent yet. Run ${orange("clawcard keys create")} to create one.`
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
options = [
|
|
229
|
+
...(!hasBalance
|
|
230
|
+
? [{ value: "billing", label: "Top up balance", hint: "required — minimum $5 to get started" }]
|
|
231
|
+
: !hasAgent
|
|
232
|
+
? [{ value: "keys-create", label: "Create agent", hint: "you have balance — create your agent now" }]
|
|
233
|
+
: [{ value: "agent", label: "My Agent", hint: "email, phone, key details" }]),
|
|
234
|
+
...(hasAgent
|
|
235
|
+
? [{ value: "setup", label: "Setup", hint: "set up your agent" }]
|
|
236
|
+
: []),
|
|
237
|
+
{ value: "billing", label: "Billing", hint: "check balance & top up" },
|
|
238
|
+
{ value: "referral", label: "Referral", hint: "share & earn $5" },
|
|
239
|
+
{ value: "whoami", label: "Who am I?", hint: "show current account" },
|
|
240
|
+
{ value: "logout", label: "Logout", hint: "clear session" },
|
|
241
|
+
{ value: "help", label: "Help", hint: "show all commands" },
|
|
242
|
+
];
|
|
243
|
+
}
|
|
216
244
|
|
|
217
245
|
const action = await p.select({
|
|
218
246
|
message: "What would you like to do?",
|
|
@@ -230,6 +258,7 @@ if (process.argv.length <= 2) {
|
|
|
230
258
|
logout: () => import("./commands/logout.js").then((m) => m.logoutCommand()),
|
|
231
259
|
whoami: () => import("./commands/whoami.js").then((m) => m.whoamiCommand()),
|
|
232
260
|
agent: () => import("./commands/keys.js").then((m) => m.agentStatusCommand()),
|
|
261
|
+
"keys-create": () => import("./commands/keys.js").then((m) => m.keysCreateCommand()),
|
|
233
262
|
keys: () => import("./commands/keys.js").then((m) => m.keysCommand()),
|
|
234
263
|
setup: () => import("./commands/setup.js").then((m) => m.setupCommand()),
|
|
235
264
|
billing: () =>
|