troxy-cli 1.4.22 → 1.4.23

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.
Files changed (2) hide show
  1. package/bin/troxy.js +30 -2
  2. package/package.json +1 -1
package/bin/troxy.js CHANGED
@@ -170,6 +170,10 @@ switch (command) {
170
170
  Simulates a payment evaluation request — identical to what your AI agent sends.
171
171
  Use this to test your policies. Login required.
172
172
 
173
+ By default, payments that come back ALLOW or NOTIFY are auto-confirmed as
174
+ successful charges, so rows land on their final badge in the dashboard
175
+ instead of sitting in PENDING. Pass --no-confirm to skip that step.
176
+
173
177
  Required:
174
178
  --merchant <name> Merchant name (e.g. "Amazon")
175
179
  --amount <n> Payment amount in USD
@@ -177,11 +181,14 @@ switch (command) {
177
181
  Optional:
178
182
  --card <alias> Card alias (default: "Work")
179
183
  --category <cat> Merchant category (e.g. travel, software, food)
184
+ --no-confirm Don't auto-confirm — leaves the row PENDING
185
+ --fail Confirm as a failed charge instead of success
186
+ (simulates a declined card)
180
187
 
181
188
  Examples:
182
189
  troxy pay --merchant "Amazon" --amount 50
183
- troxy pay --merchant "Amazon" --amount 350 --card "Work"
184
- troxy pay --merchant "Delta" --amount 250 --card "Work" --category travel
190
+ troxy pay --merchant "Amazon" --amount 350 --no-confirm
191
+ troxy pay --merchant "Delta" --amount 250 --fail
185
192
  `);
186
193
  process.exit(0);
187
194
  }
@@ -192,6 +199,8 @@ switch (command) {
192
199
  const amount = parseFloat(flags.amount);
193
200
  const card = flags.card || 'Work';
194
201
  const category = flags.category;
202
+ const noConfirm = !!flags['no-confirm'];
203
+ const failCharge = !!flags.fail;
195
204
  if (!merchant) { console.error(' --merchant is required\n'); process.exit(1); }
196
205
  if (isNaN(amount)){ console.error(' --amount is required\n'); process.exit(1); }
197
206
  const agentName = loadConfig()?.agentName || 'troxy-cli';
@@ -203,6 +212,25 @@ switch (command) {
203
212
  const suffix = result.policy ? ` ← "${result.policy}"` : result.reason ? ` — ${result.reason}` : ' (default action)';
204
213
  console.log(`\n ${icon} ${result.decision}${suffix}`);
205
214
  if (result.audit_id) console.log(` audit: ${result.audit_id}`);
215
+
216
+ // Auto-confirm so the dashboard badge lands on its final state. ALLOW and
217
+ // NOTIFY decisions normally leave the row PENDING until the agent reports
218
+ // back; for CLI testing that's just noise, so we confirm-success by
219
+ // default. BLOCK and ESCALATE are final / human-gated and aren't touched.
220
+ const shouldConfirm = !noConfirm && result.audit_id && ['ALLOW', 'NOTIFY'].includes(result.decision);
221
+ if (shouldConfirm) {
222
+ const status = failCharge ? 'failed' : 'success';
223
+ try {
224
+ await api.confirmPayment(result.audit_id, {
225
+ status,
226
+ provider: 'troxy-cli',
227
+ ...(failCharge ? { reason: 'simulated card decline (--fail)' } : {}),
228
+ }, apiKey);
229
+ console.log(` confirmed: charge ${status}`);
230
+ } catch (e) {
231
+ console.log(` (confirm step failed — row will stay PENDING)`);
232
+ }
233
+ }
206
234
  console.log();
207
235
  break;
208
236
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "troxy-cli",
3
- "version": "1.4.22",
3
+ "version": "1.4.23",
4
4
  "description": "AI payment control — protect your agent's payments with policies",
5
5
  "type": "module",
6
6
  "bin": {