troxy-cli 1.30.2 → 1.30.3

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.30.2",
3
+ "version": "1.30.3",
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": {
@@ -235,7 +235,7 @@ const REPORT_KEEP_ROWS = 1000; // kept for the next try while Troxy is unreachab
235
235
  let pending = [];
236
236
  let compacting = false;
237
237
 
238
- function reportRow({ sid, usage, requested, arm, cold, score, compact, rateLimits, ts, effort, effortAsked }) {
238
+ function reportRow({ sid, usage, requested, arm, cold, score, compact, rateLimits, ts, effort, effortAsked, surfaces }) {
239
239
  const rl = {};
240
240
  for (const w of rateLimits || []) {
241
241
  if (!WINDOW_LABEL[w.kind]) continue;
@@ -248,6 +248,7 @@ function reportRow({ sid, usage, requested, arm, cold, score, compact, rateLimit
248
248
  compact: Boolean(compact), input_tokens: usage.input_tokens, output_tokens: usage.output_tokens,
249
249
  cache_read_tokens: usage.cache_read_input_tokens, cache_creation_tokens: usage.cache_creation_input_tokens,
250
250
  rate_limits: rl, ts, effort: effort || null, effort_requested: effortAsked || null,
251
+ surface: (surfaces || []).includes('desktop') ? 'desktop' : (surfaces || []).includes('terminal') ? 'terminal' : null,
251
252
  };
252
253
  }
253
254
 
@@ -256,7 +257,9 @@ async function noteStep($, result, meta) {
256
257
  if (!usage || !usage.model) return;
257
258
  let rateLimits = [];
258
259
  try { rateLimits = (await $.session.usage()).rateLimits; } catch {}
259
- pending.push(reportRow({ ...meta, sid: await $.session.id(), usage, compact: compacting, rateLimits, ts: await $.clock.now() }));
260
+ let surfaces = [];
261
+ try { surfaces = await $.session.surfaces(); } catch {}
262
+ pending.push(reportRow({ ...meta, sid: await $.session.id(), usage, compact: compacting, rateLimits, surfaces, ts: await $.clock.now() }));
260
263
  if (pending.length > REPORT_KEEP_ROWS) pending = pending.slice(-REPORT_KEEP_ROWS);
261
264
  }
262
265
 
@@ -432,3 +432,11 @@ test('routeStep: with the effort swap on, an easy prompt goes out at low effort
432
432
  assert.equal(pendingRows().at(-1).effort, 'low');
433
433
  assert.equal(pendingRows().at(-1).effort_requested, 'high');
434
434
  });
435
+
436
+ test('reportRow: surface is desktop when the app draws the session, terminal otherwise, null in -p', () => {
437
+ const { reportRow } = _internal;
438
+ const base = { sid: 's', usage: { model: 'm' } };
439
+ assert.equal(reportRow({ ...base, surfaces: ['terminal', 'desktop'] }).surface, 'desktop');
440
+ assert.equal(reportRow({ ...base, surfaces: ['terminal'] }).surface, 'terminal');
441
+ assert.equal(reportRow({ ...base, surfaces: [] }).surface, null);
442
+ });