opencode-studio-server 1.3.2 → 1.3.4
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/index.js +7 -1
- package/package.json +1 -1
- package/server.live.err.log +0 -0
- package/server.live.log +1 -0
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;
|
|
@@ -1620,7 +1626,7 @@ app.get('/api/presets', (req, res) => {
|
|
|
1620
1626
|
app.post('/api/presets', (req, res) => {
|
|
1621
1627
|
const { name, description, config } = req.body;
|
|
1622
1628
|
const studio = loadStudioConfig();
|
|
1623
|
-
const id = crypto.randomUUID();
|
|
1629
|
+
const id = crypto.randomUUID ? crypto.randomUUID() : crypto.randomBytes(16).toString('hex');
|
|
1624
1630
|
const preset = { id, name, description, config };
|
|
1625
1631
|
studio.presets = studio.presets || [];
|
|
1626
1632
|
studio.presets.push(preset);
|
package/package.json
CHANGED
|
File without changes
|
package/server.live.log
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Server running at http://localhost:3001
|