opencode-studio-server 1.3.2 → 1.3.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.
Files changed (2) hide show
  1. package/index.js +6 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1227,13 +1227,18 @@ app.get('/api/usage', async (req, res) => {
1227
1227
  const stats = { totalCost: 0, totalTokens: 0, byModel: {}, byTime: {}, byProject: {} };
1228
1228
  const seen = new Set();
1229
1229
  const now = Date.now();
1230
+ const from = Number(req.query.from || 0);
1231
+ const to = Number(req.query.to || 0);
1230
1232
  let min = 0;
1233
+ let max = 0;
1231
1234
  if (range === '24h') min = now - 86400000;
1232
1235
  else if (range === '7d') min = now - 604800000;
1233
1236
  else if (range === '30d') min = now - 2592000000;
1234
1237
  else if (range === '3m') min = now - 7776000000;
1235
1238
  else if (range === '6m') min = now - 15552000000;
1236
1239
  else if (range === '1y') min = now - 31536000000;
1240
+ if (from) min = from;
1241
+ if (to) max = to;
1237
1242
 
1238
1243
  const sessionDirs = await fs.promises.readdir(md);
1239
1244
  await Promise.all(sessionDirs.map(async s => {
@@ -1254,6 +1259,7 @@ app.get('/api/usage', async (req, res) => {
1254
1259
  const pid = pmap.get(s)?.id || 'unknown';
1255
1260
  if (fid && fid !== 'all' && pid !== fid) continue;
1256
1261
  if (min > 0 && msg.time.created < min) continue;
1262
+ if (max > 0 && msg.time.created > max) continue;
1257
1263
 
1258
1264
  if (msg.role === 'assistant' && msg.tokens) {
1259
1265
  const c = msg.cost || 0, it = msg.tokens.input || 0, ot = msg.tokens.output || 0, t = it + ot;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-studio-server",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "Backend server for OpenCode Studio - manages opencode configurations",
5
5
  "main": "index.js",
6
6
  "bin": {