@clawcard/cli 1.1.1 → 1.1.2
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/help.js +3 -0
- package/src/commands/keys.js +44 -10
- package/src/index.js +16 -1
package/package.json
CHANGED
package/src/commands/help.js
CHANGED
|
@@ -11,6 +11,9 @@ const COMMANDS = [
|
|
|
11
11
|
[" logout", "Clear session"],
|
|
12
12
|
[" whoami", "Show current account"],
|
|
13
13
|
["", ""],
|
|
14
|
+
[orange.bold("Agent"), ""],
|
|
15
|
+
[" agent", "Show your agent's identity"],
|
|
16
|
+
["", ""],
|
|
14
17
|
[orange.bold("Keys"), ""],
|
|
15
18
|
[" keys", "Interactive key management"],
|
|
16
19
|
[" keys create", "Create a new API key"],
|
package/src/commands/keys.js
CHANGED
|
@@ -102,16 +102,15 @@ export async function keysCreateCommand() {
|
|
|
102
102
|
p.log.success("Copied to clipboard");
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
105
|
+
// Show provisioned resources
|
|
106
|
+
const details = [
|
|
107
|
+
`Name: ${orange.bold(result.name || "unnamed")}`,
|
|
108
|
+
result.email && `Email: ${result.email}`,
|
|
109
|
+
result.phone && `Phone: ${result.phone}`,
|
|
110
|
+
`Limit: $${(result.spendLimitCents / 100).toFixed(2)}`,
|
|
111
|
+
].filter(Boolean).join("\n");
|
|
112
|
+
|
|
113
|
+
p.note(details, "Your Agent");
|
|
115
114
|
} catch (err) {
|
|
116
115
|
s.stop("Failed to create key");
|
|
117
116
|
p.log.error(err.message);
|
|
@@ -209,6 +208,41 @@ export async function keysInfoCommand(keyIdOrPrefix) {
|
|
|
209
208
|
}
|
|
210
209
|
}
|
|
211
210
|
|
|
211
|
+
export async function agentStatusCommand() {
|
|
212
|
+
requireAuth();
|
|
213
|
+
|
|
214
|
+
const s = p.spinner();
|
|
215
|
+
s.start("Fetching agent...");
|
|
216
|
+
|
|
217
|
+
try {
|
|
218
|
+
const agents = await listAgents();
|
|
219
|
+
const active = agents.filter((a) => a.status === "active");
|
|
220
|
+
|
|
221
|
+
if (!active.length) {
|
|
222
|
+
s.stop("");
|
|
223
|
+
p.log.info("No active agent. Create one with: clawcard keys create");
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const agent = await getAgent(active[0].id);
|
|
228
|
+
s.stop("");
|
|
229
|
+
|
|
230
|
+
const info = [
|
|
231
|
+
`Name: ${orange.bold(agent.name || "unnamed")}`,
|
|
232
|
+
`Key: ${chalk.dim(agent.keyPrefix + "...")}`,
|
|
233
|
+
`Email: ${agent.email || "-"}`,
|
|
234
|
+
`Phone: ${agent.phone || "-"}`,
|
|
235
|
+
`Limit: $${(agent.spendLimitCents / 100).toFixed(2)}`,
|
|
236
|
+
`Status: ${chalk.green("active")}`,
|
|
237
|
+
].join("\n");
|
|
238
|
+
|
|
239
|
+
p.note(info, "Your Agent");
|
|
240
|
+
} catch (err) {
|
|
241
|
+
s.stop("Failed");
|
|
242
|
+
p.log.error(err.message);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
212
246
|
export async function keysRevokeCommand() {
|
|
213
247
|
requireAuth();
|
|
214
248
|
|
package/src/index.js
CHANGED
|
@@ -88,6 +88,15 @@ keys
|
|
|
88
88
|
await keysRevokeCommand();
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
+
// Agent status
|
|
92
|
+
program
|
|
93
|
+
.command("agent")
|
|
94
|
+
.description("Show your agent's identity (email, phone, key)")
|
|
95
|
+
.action(async () => {
|
|
96
|
+
const { agentStatusCommand } = await import("./commands/keys.js");
|
|
97
|
+
await agentStatusCommand();
|
|
98
|
+
});
|
|
99
|
+
|
|
91
100
|
// Setup
|
|
92
101
|
program
|
|
93
102
|
.command("setup")
|
|
@@ -179,13 +188,18 @@ if (process.argv.length <= 2) {
|
|
|
179
188
|
|
|
180
189
|
const options = loggedIn
|
|
181
190
|
? [
|
|
191
|
+
{
|
|
192
|
+
value: "agent",
|
|
193
|
+
label: "My Agent",
|
|
194
|
+
hint: "email, phone, key details",
|
|
195
|
+
},
|
|
182
196
|
{
|
|
183
197
|
value: "setup",
|
|
184
198
|
label: "Setup",
|
|
185
199
|
hint: "set up your agent",
|
|
186
200
|
},
|
|
187
201
|
{ value: "billing", label: "Billing", hint: "check balance & top up" },
|
|
188
|
-
{ value: "referral", label: "Referral", hint: "share & earn $
|
|
202
|
+
{ value: "referral", label: "Referral", hint: "share & earn $5" },
|
|
189
203
|
{ value: "whoami", label: "Who am I?", hint: "show current account" },
|
|
190
204
|
{ value: "logout", label: "Logout", hint: "clear session" },
|
|
191
205
|
{ value: "help", label: "Help", hint: "show all commands" },
|
|
@@ -215,6 +229,7 @@ if (process.argv.length <= 2) {
|
|
|
215
229
|
signup: () => import("./commands/signup.js").then((m) => m.signupCommand()),
|
|
216
230
|
logout: () => import("./commands/logout.js").then((m) => m.logoutCommand()),
|
|
217
231
|
whoami: () => import("./commands/whoami.js").then((m) => m.whoamiCommand()),
|
|
232
|
+
agent: () => import("./commands/keys.js").then((m) => m.agentStatusCommand()),
|
|
218
233
|
keys: () => import("./commands/keys.js").then((m) => m.keysCommand()),
|
|
219
234
|
setup: () => import("./commands/setup.js").then((m) => m.setupCommand()),
|
|
220
235
|
billing: () =>
|