@troxy/cli 0.1.9 → 0.2.1

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/troxy.js CHANGED
@@ -59,6 +59,14 @@ switch (command) {
59
59
  await runActivity(flags);
60
60
  break;
61
61
 
62
+ // ── Shorthand: troxy list [cards|policies|activity] ───────────
63
+ case 'list':
64
+ if (!sub || sub === 'cards') { await runCards(['list'], flags); break; }
65
+ if (sub === 'policies') { await runPolicies(['list'], flags); break; }
66
+ if (sub === 'activity') { await runActivity(flags); break; }
67
+ console.error(` Unknown resource: ${sub}. Try: cards, policies, activity\n`);
68
+ process.exit(1);
69
+
62
70
  // ── Status ────────────────────────────────────────────────────
63
71
  case 'status': {
64
72
  const health = await api.health();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@troxy/cli",
3
- "version": "0.1.9",
3
+ "version": "0.2.1",
4
4
  "description": "AI payment control — protect your agent's payments with policies",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cards.js CHANGED
@@ -8,17 +8,18 @@ export async function runCards([sub, ...args], flags) {
8
8
  switch (sub) {
9
9
  case 'list':
10
10
  case undefined: {
11
- const cards = await api.listCards(jwt);
11
+ const data = await api.listCards(jwt);
12
+ const cards = data?.cards || [];
12
13
  if (!cards.length) { console.log('\n No cards yet.\n'); return; }
13
14
  console.log();
14
15
  table(
15
- ['Name', 'Status', 'Budget', 'Used', 'Provider'],
16
+ ['Name', 'Last 4', 'Status', 'Budget', 'Used'],
16
17
  cards.map(c => [
17
- c.alias_name,
18
+ c.name,
19
+ c.last_four ? `···${c.last_four}` : '—',
18
20
  c.status,
19
- c.monthly_budget ? `$${c.monthly_budget}` : '',
20
- c.budget_used ? `$${Number(c.budget_used).toFixed(2)}` : '$0.00',
21
- c.provider || '—',
21
+ c.monthly_budget ? `$${c.monthly_budget}` : 'no limit',
22
+ `$${Number(c.budget_used || 0).toFixed(2)}`,
22
23
  ]),
23
24
  );
24
25
  break;
@@ -42,8 +43,9 @@ export async function runCards([sub, ...args], flags) {
42
43
  case 'delete': {
43
44
  const name = flags.name;
44
45
  if (!name) { console.error(' --name is required\n'); process.exit(1); }
45
- const cards = await api.listCards(jwt);
46
- const card = cards.find(c => c.alias_name === name);
46
+ const data = await api.listCards(jwt);
47
+ const cards = data?.cards || [];
48
+ const card = cards.find(c => c.name === name);
47
49
  if (!card) { console.error(` Card "${name}" not found\n`); process.exit(1); }
48
50
  await api.deleteCard(jwt, card.id);
49
51
  console.log(`\n Card "${name}" deleted ✓\n`);
package/src/policies.js CHANGED
@@ -8,7 +8,8 @@ export async function runPolicies([sub, ...args], flags) {
8
8
  switch (sub) {
9
9
  case 'list':
10
10
  case undefined: {
11
- const policies = await api.listPolicies(jwt);
11
+ const data = await api.listPolicies(jwt);
12
+ const policies = data?.policies || [];
12
13
  if (!policies.length) { console.log('\n No policies yet.\n'); return; }
13
14
  console.log();
14
15
  table(
@@ -60,7 +61,7 @@ export async function runPolicies([sub, ...args], flags) {
60
61
  case 'delete': {
61
62
  const name = flags.name;
62
63
  if (!name) { console.error(' --name is required\n'); process.exit(1); }
63
- const policies = await api.listPolicies(jwt);
64
+ const { policies = [] } = await api.listPolicies(jwt);
64
65
  const policy = policies.find(p => p.name === name);
65
66
  if (!policy) { console.error(` Policy "${name}" not found\n`); process.exit(1); }
66
67
  await api.deletePolicy(jwt, policy.id);
@@ -72,7 +73,7 @@ export async function runPolicies([sub, ...args], flags) {
72
73
  case 'disable': {
73
74
  const name = flags.name;
74
75
  if (!name) { console.error(' --name is required\n'); process.exit(1); }
75
- const policies = await api.listPolicies(jwt);
76
+ const { policies = [] } = await api.listPolicies(jwt);
76
77
  const policy = policies.find(p => p.name === name);
77
78
  if (!policy) { console.error(` Policy "${name}" not found\n`); process.exit(1); }
78
79
  await api.updatePolicy(jwt, policy.id, { enabled: sub === 'enable' });