troxy-cli 1.2.3 → 1.2.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/bin/troxy.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { runInit } from '../src/init.js';
3
3
  import { runUninstall } from '../src/uninstall.js';
4
4
  import { runMcp } from '../src/mcp-server.js';
5
- import { runLogin, clearSession, requireKey, getKeySource } from '../src/auth.js';
5
+ import { runLogin, clearSession, requireKey, requireJwt, getKeySource } from '../src/auth.js';
6
6
  import { runPolicies } from '../src/policies.js';
7
7
  import { runMcps } from '../src/mcps.js';
8
8
  import { runActivity } from '../src/activity.js';
@@ -127,6 +127,26 @@ switch (command) {
127
127
  await runMcp();
128
128
  break;
129
129
 
130
+ // ── Simulate a payment evaluation ────────────────────────────
131
+ case 'pay': {
132
+ const apiKey = requireKey(flags);
133
+ const merchant = flags.merchant;
134
+ const amount = parseFloat(flags.amount);
135
+ const card = flags.card || 'Work';
136
+ const category = flags.category;
137
+ if (!merchant) { console.error(' --merchant is required\n'); process.exit(1); }
138
+ if (isNaN(amount)){ console.error(' --amount is required\n'); process.exit(1); }
139
+ const body = { card_alias: card, merchant_name: merchant, amount, agent: 'troxy-cli' };
140
+ if (category) body.merchant_category = category;
141
+ const result = await api.evaluate(body, apiKey);
142
+ const ICON = { ALLOW: '✓', BLOCK: '✗', ESCALATE: '⏳', NOTIFY: '~' };
143
+ const icon = ICON[result.decision] || '?';
144
+ console.log(`\n ${icon} ${result.decision}${result.policy ? ` ← "${result.policy}"` : ' (default action)'}`);
145
+ if (result.audit_id) console.log(` audit: ${result.audit_id}`);
146
+ console.log();
147
+ break;
148
+ }
149
+
130
150
  // ── Resources (read-only: --key or saved config; write: login) ─
131
151
  case 'policies':
132
152
  await runPolicies(positional, flags);
@@ -238,6 +258,10 @@ switch (command) {
238
258
  troxy uninstall Remove Troxy from this machine
239
259
  troxy status API health + which key is in use
240
260
 
261
+ Simulate
262
+ troxy pay --merchant "Amazon" --amount 50 --card "Work"
263
+ troxy pay --merchant "Google" --amount 300 --card "Work" --category software
264
+
241
265
  Inspect (uses saved key — no flags needed after init)
242
266
  troxy policies list
243
267
  troxy policies describe --name "Block Amazon"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "troxy-cli",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "description": "AI payment control — protect your agent's payments with policies",
5
5
  "type": "module",
6
6
  "bin": {
package/src/policies.js CHANGED
@@ -126,7 +126,17 @@ function _condSummary(p) {
126
126
  }
127
127
 
128
128
  function _condDetail(p) {
129
- const c = p.conditions || [];
130
- if (!c.length) return 'none (always matches)';
131
- return c.map(x => `${x.field} ${x.operator} ${x.value || ''}${x.value2 ? '–'+x.value2 : ''}`).join(' AND ');
129
+ const c = p.conditions || [];
130
+ const or = p.or_conditions || [];
131
+ const parts = [];
132
+ if (c.length) {
133
+ parts.push(c.map(x => `${x.field} ${x.operator} ${x.value || ''}${x.value2 ? '–'+x.value2 : ''}`).join(' AND '));
134
+ }
135
+ if (or.length) {
136
+ or.forEach(row => {
137
+ const conds = (row.conditions || []).map(x => `${x.field} ${x.operator} ${x.value || ''}`).join(' AND ');
138
+ parts.push(`${row.action}${conds ? ' if ' + conds : ''}`);
139
+ });
140
+ }
141
+ return parts.length ? parts.join('\n ') : 'none (always matches)';
132
142
  }