troxy-cli 1.29.35 → 1.29.37
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "troxy-cli",
|
|
3
|
-
"version": "1.29.
|
|
3
|
+
"version": "1.29.37",
|
|
4
4
|
"description": "A secure control layer for AI agents: policies across payments, messages, logins, destructive actions, model usage, and secrets, all enforceable from the CLI",
|
|
5
5
|
"homepage": "https://troxy.io",
|
|
6
6
|
"bugs": {
|
|
@@ -112,8 +112,6 @@ function troxyCommand(args, paused) {
|
|
|
112
112
|
return { paused, text: paused ? 'Troxy routing is off. Type /troxy on to resume.' : 'Troxy routing is on. Type /troxy off to pause it.' };
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
// Whether this session has shown its one "Troxy is active" notice yet.
|
|
116
|
-
let announced = false;
|
|
117
115
|
|
|
118
116
|
// Session savings tracking: cumulative % savings from routing
|
|
119
117
|
let sessionSavingsPercent = 0;
|
|
@@ -133,6 +131,12 @@ function calculateSavings(fromModel, toModel) {
|
|
|
133
131
|
return Math.round(((fromCost - toCost) / fromCost) * 100);
|
|
134
132
|
}
|
|
135
133
|
|
|
134
|
+
// Status-line text for the running session savings, e.g. [████░░░░░░░░░░░░░░░░] Troxy: -20% saved
|
|
135
|
+
function savingsBar() {
|
|
136
|
+
const filled = Math.round((sessionSavingsPercent / 100) * 20);
|
|
137
|
+
return `[${'█'.repeat(filled)}${'░'.repeat(20 - filled)}] Troxy: -${sessionSavingsPercent}% saved`;
|
|
138
|
+
}
|
|
139
|
+
|
|
136
140
|
// Where the local daemon looks for this session's routing note (see interceptor.js).
|
|
137
141
|
// Only when installed under ~/.claude/skills, so a --plugin-dir test run never writes
|
|
138
142
|
// into a real user's folder.
|
|
@@ -177,10 +181,7 @@ async function* routeStep($, e, next) {
|
|
|
177
181
|
if (savings > 0) {
|
|
178
182
|
routingCount += 1;
|
|
179
183
|
sessionSavingsPercent = Math.round((sessionSavingsPercent * (routingCount - 1) + savings) / routingCount);
|
|
180
|
-
|
|
181
|
-
if (!announced) {
|
|
182
|
-
announced = true;
|
|
183
|
-
$.ui.toast(`Troxy is active · Session: -${sessionSavingsPercent}% saved`);
|
|
184
|
+
$.ui.status(savingsBar());
|
|
184
185
|
}
|
|
185
186
|
const sid = await $.session.id();
|
|
186
187
|
const file = modRouteFile($.plugin.root, sid);
|
|
@@ -202,22 +203,9 @@ export function register(on) {
|
|
|
202
203
|
on('command.run', { command: 'troxy' }, async ($, e) => {
|
|
203
204
|
const r = troxyCommand(e.args, Boolean(await $.store.get('paused')));
|
|
204
205
|
await $.store.set('paused', r.paused);
|
|
206
|
+
if (r.paused) $.ui.status(undefined);
|
|
205
207
|
return { text: r.text };
|
|
206
208
|
});
|
|
207
|
-
// Visual savings bar in terminal output
|
|
208
|
-
on('turn.start', async ($, e, next) => {
|
|
209
|
-
const paused = Boolean(await $.store.get('paused'));
|
|
210
|
-
|
|
211
|
-
if (!paused && routingCount > 0) {
|
|
212
|
-
const barLength = 20;
|
|
213
|
-
const filledLength = Math.round((sessionSavingsPercent / 100) * barLength);
|
|
214
|
-
const emptyLength = barLength - filledLength;
|
|
215
|
-
const bar = '█'.repeat(filledLength) + '░'.repeat(emptyLength);
|
|
216
|
-
console.log(`\n[${bar}] Troxy: -${sessionSavingsPercent}% saved\n`);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return next(e);
|
|
220
|
-
});
|
|
221
209
|
// Routing fails open: a scorer or hook error must never break the session,
|
|
222
210
|
// it just means the requested model is used as-is.
|
|
223
211
|
on('prompt.submit', scorePrompt).catch(($, e, next) => { decision = null; return next(e); });
|