troxy-cli 1.2.3 → 1.2.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/bin/troxy.js +24 -0
- package/package.json +1 -1
package/bin/troxy.js
CHANGED
|
@@ -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"
|