troxy-cli 1.4.22 → 1.5.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
@@ -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.5.0",
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
@@ -15,14 +15,14 @@ const HELP = {
15
15
  describe: ` troxy policies describe --name <policy-name>\n\n Shows full details for a single policy.\n\n Options:\n --name Name of the policy (use single quotes for names with special chars)\n`,
16
16
  create: ` troxy policies create --name <name> --action <action> [options]\n\n Creates a new policy. Login required.\n\n Required:\n --name Policy name\n --action ALLOW, BLOCK, NOTIFY, or ESCALATE\n\n Optional conditions:\n --field Field to match: amount, merchant_name, tx_per_day\n --operator eq, neq, gt, gte, lt, lte, contains, starts_with, not_contains, between\n --value Comparison value (e.g. 500, amazon)\n --value2 Upper bound for 'between' operator\n\n Priority:\n --priority <n> Explicit priority number (default: auto, max+10)\n Lower number = higher priority (evaluated first).\n\n Scope:\n --mcp <name> Scope policy to a specific MCP only (default: all MCPs)\n Run 'troxy mcps list' to see MCP names.\n\n Examples:\n troxy policies create --name "Block large" --action BLOCK --field amount --operator gte --value 500\n troxy policies create --name "Block Amazon" --action BLOCK --field merchant_name --operator contains --value amazon\n troxy policies create --name "Cap volume" --action BLOCK --field tx_per_day --operator gt --value 20\n troxy policies create --name "Allow Wiki" --action ALLOW --priority 5 --field merchant_name --operator contains --value Wiki\n`,
17
17
  'set-priority': ` troxy policies set-priority --name <policy-name> --priority <n>\n\n Changes the priority of a policy. Lower number = higher priority (evaluated first).\n\n Options:\n --name Name of the policy\n --priority New priority number (e.g. 10, 20, 50)\n\n Example:\n troxy policies set-priority --name "Block Wiki" --priority 5\n`,
18
- enable: ` troxy policies enable --name <policy-name>\n\n Enables a disabled policy.\n\n Options:\n --name Name of the policy to enable\n`,
19
- disable: ` troxy policies disable --name <policy-name>\n\n Disables a policy without deleting it.\n\n Options:\n --name Name of the policy to disable\n`,
18
+ resume: ` troxy policies resume --name <policy-name>\n\n Resumes a paused policy.\n\n Options:\n --name Name of the policy to resume\n`,
19
+ pause: ` troxy policies pause --name <policy-name>\n\n Pauses a policy without deleting it. The policy stops firing until you resume it.\n\n Options:\n --name Name of the policy to pause\n`,
20
20
  delete: ` troxy policies delete --name <policy-name>\n\n Permanently deletes a policy.\n\n Options:\n --name Name of the policy to delete\n`,
21
21
  };
22
22
 
23
23
  export async function runPolicies([sub, ...args], flags) {
24
24
  if (flags.help || flags.h) {
25
- console.log('\n' + (HELP[sub] || ` troxy policies <subcommand> [options]\n\n Subcommands:\n list List all policies\n describe Show details for a policy\n create Create a new policy\n set-priority Change a policy's priority\n enable Enable a policy\n disable Disable a policy\n delete Delete a policy\n\n Run 'troxy policies <subcommand> --help' for subcommand help.\n`));
25
+ console.log('\n' + (HELP[sub] || ` troxy policies <subcommand> [options]\n\n Subcommands:\n list List all policies\n describe Show details for a policy\n create Create a new policy\n set-priority Change a policy's priority\n pause Pause a policy (it stops firing until you resume it)\n resume Resume a paused policy\n delete Delete a policy\n\n Run 'troxy policies <subcommand> --help' for subcommand help.\n`));
26
26
  process.exit(0);
27
27
  }
28
28
 
@@ -44,7 +44,7 @@ export async function runPolicies([sub, ...args], flags) {
44
44
  p.name,
45
45
  p.action,
46
46
  _scope(p),
47
- p.enabled ? 'enabled' : 'disabled',
47
+ p.enabled ? 'active' : 'paused',
48
48
  _condSummary(p),
49
49
  p.applies_to_me ? '✓' : '—',
50
50
  ]),
@@ -63,7 +63,7 @@ export async function runPolicies([sub, ...args], flags) {
63
63
  Name: ${p.name}
64
64
  Action: ${p.action}
65
65
  Priority: ${p.priority}
66
- Status: ${p.enabled ? 'enabled' : 'disabled'}
66
+ Status: ${p.enabled ? 'active' : 'paused'}
67
67
  Scope: ${p.scope}
68
68
  Applies here: ${p.applies_to_me ? 'yes' : 'no'}
69
69
  MCPs: ${p.mcps.length ? p.mcps.map(m => m.name).join(', ') : p.global ? 'all MCPs' : 'none'}
@@ -159,6 +159,13 @@ export async function runPolicies([sub, ...args], flags) {
159
159
 
160
160
  case 'enable':
161
161
  case 'disable': {
162
+ // Old vocabulary — hard-renamed to resume/pause. Tell the user, exit.
163
+ const replacement = sub === 'enable' ? 'resume' : 'pause';
164
+ console.error(`\n '${sub}' was renamed to '${replacement}'.\n Run: troxy policies ${replacement} --name "<policy-name>"\n`);
165
+ process.exit(2);
166
+ }
167
+ case 'pause':
168
+ case 'resume': {
162
169
  const name = flags.name;
163
170
  if (!name) { console.error(' --name is required\n'); process.exit(1); }
164
171
  const { policies = [] } = await api.listPolicies(jwt);
@@ -172,7 +179,7 @@ export async function runPolicies([sub, ...args], flags) {
172
179
  or_conditions: policy.or_conditions || [],
173
180
  tiers: policy.tiers || null,
174
181
  global: policy.global !== false,
175
- enabled: sub === 'enable',
182
+ enabled: sub === 'resume',
176
183
  });
177
184
  console.log(`\n Policy "${name}" ${sub}d ✓\n`);
178
185
  break;