troxy-cli 1.3.9 → 1.4.1

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,6 +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 { runPause, runResume } from '../src/pause.js';
5
6
  import { runLogin, clearSession, requireKey, requireJwt, loadSession, getKeySource } from '../src/auth.js';
6
7
  import { loadConfig } from '../src/config.js';
7
8
  import { runPolicies } from '../src/policies.js';
@@ -131,6 +132,15 @@ switch (command) {
131
132
  await runMcp();
132
133
  break;
133
134
 
135
+ // ── Pause / resume payment evaluations ───────────────────────
136
+ case 'pause':
137
+ await runPause();
138
+ break;
139
+
140
+ case 'resume':
141
+ await runResume();
142
+ break;
143
+
134
144
  // ── Simulate a payment evaluation ────────────────────────────
135
145
  case 'pay': {
136
146
  const apiKey = requireKey(flags);
@@ -230,7 +240,21 @@ switch (command) {
230
240
  // MCP connection info from local config (set by troxy init)
231
241
  const localKey = loadConfig()?.apiKey;
232
242
  if (localKey) {
233
- console.log(` MCP key: ${localKey.substring(0, 12)}... (saved — run \`troxy init\` to change)\n`);
243
+ process.stdout.write(` MCP key: ${localKey.substring(0, 12)}...`);
244
+ try {
245
+ const mcpStatus = await api.mcpStatus(localKey);
246
+ if (mcpStatus.paused) {
247
+ process.stdout.write(` ⏸ PAUSED (run \`troxy resume\` to resume)\n`);
248
+ } else {
249
+ const lastSeen = mcpStatus.mcp_last_seen_at
250
+ ? ` last seen ${new Date(mcpStatus.mcp_last_seen_at).toLocaleString()}`
251
+ : '';
252
+ process.stdout.write(` ✓ active${lastSeen}\n`);
253
+ }
254
+ } catch {
255
+ process.stdout.write('\n');
256
+ }
257
+ console.log();
234
258
  }
235
259
 
236
260
  // Version check
@@ -268,6 +292,8 @@ switch (command) {
268
292
  troxy rotate-key --revoke-old Same + revoke the old key immediately
269
293
  troxy uninstall Remove Troxy from this machine
270
294
  troxy status API health + account overview
295
+ troxy pause Pause this MCP (blocks all payments until resumed)
296
+ troxy resume Resume this MCP after a pause
271
297
 
272
298
  Inspect (requires: troxy login)
273
299
  troxy policies list
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "troxy-cli",
3
- "version": "1.3.9",
3
+ "version": "1.4.1",
4
4
  "description": "AI payment control — protect your agent's payments with policies",
5
5
  "type": "module",
6
6
  "bin": {
package/src/api.js CHANGED
@@ -58,6 +58,11 @@ export const api = {
58
58
  // MCP heartbeat (agent API key)
59
59
  mcpHeartbeat: (apiKey, agentName) => request('POST', '/mcp/heartbeat', { apiKey, body: agentName ? { agent_name: agentName } : undefined }),
60
60
 
61
+ // MCP status / pause / resume (agent API key)
62
+ mcpStatus: (apiKey) => request('GET', '/mcp/status', { apiKey }),
63
+ mcpPause: (apiKey) => request('POST', '/mcp/pause', { apiKey }),
64
+ mcpResume: (apiKey) => request('POST', '/mcp/resume', { apiKey }),
65
+
61
66
  // Agent read-only API (JWT session auth — run: troxy login)
62
67
  agentStatus: (jwt) => request('GET', '/agent/status', { jwt }),
63
68
  agentPolicies: (jwt) => request('GET', '/agent/policies', { jwt }),
package/src/pause.js ADDED
@@ -0,0 +1,25 @@
1
+ import { loadConfig } from './config.js';
2
+ import { api } from './api.js';
3
+
4
+ export async function runPause() {
5
+ const config = loadConfig();
6
+ const apiKey = process.env.TROXY_API_KEY || config?.apiKey;
7
+ if (!apiKey) {
8
+ console.error('No API key found. Run: npx troxy init --key txy-...');
9
+ process.exit(1);
10
+ }
11
+ await api.mcpPause(apiKey);
12
+ console.log('⏸ MCP paused. All payment evaluations will be blocked.');
13
+ console.log(' Run "troxy resume" to resume.');
14
+ }
15
+
16
+ export async function runResume() {
17
+ const config = loadConfig();
18
+ const apiKey = process.env.TROXY_API_KEY || config?.apiKey;
19
+ if (!apiKey) {
20
+ console.error('No API key found. Run: npx troxy init --key txy-...');
21
+ process.exit(1);
22
+ }
23
+ await api.mcpResume(apiKey);
24
+ console.log('▶ MCP resumed. Payment evaluations are active again.');
25
+ }