troxy-cli 1.4.23 → 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/package.json +1 -1
- package/src/policies.js +13 -6
package/package.json
CHANGED
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
|
-
|
|
19
|
-
|
|
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
|
|
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 ? '
|
|
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 ? '
|
|
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 === '
|
|
182
|
+
enabled: sub === 'resume',
|
|
176
183
|
});
|
|
177
184
|
console.log(`\n Policy "${name}" ${sub}d ✓\n`);
|
|
178
185
|
break;
|