@troxy/cli 0.1.8 → 0.2.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/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.8",
3
+ "version": "0.2.0",
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,7 +8,8 @@ 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(
@@ -42,7 +43,8 @@ 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 data = await api.listCards(jwt);
47
+ const cards = data?.cards || [];
46
48
  const card = cards.find(c => c.alias_name === name);
47
49
  if (!card) { console.error(` Card "${name}" not found\n`); process.exit(1); }
48
50
  await api.deleteCard(jwt, card.id);
package/src/mcp-server.js CHANGED
@@ -109,7 +109,9 @@ export async function runMcp() {
109
109
  // Must be set up before server.connect() since stdio transport keeps the
110
110
  // event loop running but connect() may not return in all environments.
111
111
  const sendHeartbeat = () =>
112
- api.mcpHeartbeat(apiKey).catch(() => {}); // silent — don't crash MCP on network error
112
+ api.mcpHeartbeat(apiKey)
113
+ .then(() => process.stderr.write('[troxy] heartbeat ok\n'))
114
+ .catch(err => process.stderr.write(`[troxy] heartbeat failed: ${err.message}\n`));
113
115
  sendHeartbeat();
114
116
  setInterval(sendHeartbeat, 60_000);
115
117
 
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' });