@cesarus777/opencode-cgp 0.3.1 → 0.4.0
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/CHANGELOG.md +9 -0
- package/README.md +9 -3
- package/dist/cli.js +674 -21
- package/dist/core.js +49 -4
- package/dist/index.js +570 -9
- package/dist/rpc.js +129 -2
- package/dist/tui.js +128 -5
- package/dist/types/adapter.d.ts +2 -0
- package/dist/types/core.d.ts +1 -0
- package/dist/types/dashboard/command.d.ts +1 -1
- package/dist/types/dashboard/connection.d.ts +2 -0
- package/dist/types/dashboard/controller.d.ts +3 -0
- package/dist/types/dashboard/models.d.ts +42 -0
- package/dist/types/dashboard/modelview.d.ts +30 -0
- package/dist/types/dashboard/port.d.ts +6 -0
- package/dist/types/dashboard/terminal.d.ts +5 -0
- package/dist/types/dashboard/view.d.ts +3 -1
- package/dist/types/history.d.ts +1 -0
- package/dist/types/modelanalytics.d.ts +8 -0
- package/dist/types/modelanalyticsserver.d.ts +16 -0
- package/dist/types/modelseries.d.ts +43 -0
- package/dist/types/rpc.d.ts +28 -0
- package/dist/types/tui/chartformat.d.ts +1 -1
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -172,7 +172,7 @@ function reconcile(a, b) {
|
|
|
172
172
|
partial: a.partial || b.partial
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function analyzeModelRequests(records, options) {
|
|
176
176
|
const maxRequests = options.maxRequests ?? 1e5;
|
|
177
177
|
if (!Number.isSafeInteger(maxRequests) || maxRequests < 1 || maxRequests > 1e6)
|
|
178
178
|
throw new Error("maxRequests must be an integer from 1 to 1000000");
|
|
@@ -233,7 +233,7 @@ function aggregateModels(records, options) {
|
|
|
233
233
|
requests.set(key, { fact, conflict: false });
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
const
|
|
236
|
+
const accepted = [];
|
|
237
237
|
for (const { fact: r, conflict } of requests.values()) {
|
|
238
238
|
if (conflict) {
|
|
239
239
|
coverage.conflictingRequests++;
|
|
@@ -250,6 +250,22 @@ function aggregateModels(records, options) {
|
|
|
250
250
|
}
|
|
251
251
|
if (options.from !== undefined && r.completedAt < options.from || options.to !== undefined && r.completedAt >= options.to || options.model !== undefined && r.model !== options.model || options.agent !== undefined && r.agent !== options.agent)
|
|
252
252
|
continue;
|
|
253
|
+
accepted.push({ ...r, completedAt: r.completedAt });
|
|
254
|
+
}
|
|
255
|
+
const models = summarizeModelRequests(accepted);
|
|
256
|
+
coverage.partial = coverage.unscannedRecords > 0 || coverage.conflictingRequests > 0 || coverage.missingIdentityRecords > 0 || coverage.incompleteRequests > 0 || coverage.invalidTimingRequests > 0 || coverage.gapRecords > 0 || models.some((s) => s.partialRequests > 0 || s.legacyAttributionRequests > 0 || s.excludedTpsRequests > 0 || s.excludedTtftRequests > 0 || !s.model);
|
|
257
|
+
return {
|
|
258
|
+
schemaVersion: 1,
|
|
259
|
+
location: options.location,
|
|
260
|
+
models,
|
|
261
|
+
coverage,
|
|
262
|
+
requests: accepted
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
function summarizeModelRequests(requests) {
|
|
266
|
+
const groups = new Map;
|
|
267
|
+
for (const r of requests) {
|
|
268
|
+
const duration = r.completedAt - r.startedAt;
|
|
253
269
|
let group = groups.get(r.model);
|
|
254
270
|
if (!group) {
|
|
255
271
|
group = {
|
|
@@ -304,8 +320,11 @@ function aggregateModels(records, options) {
|
|
|
304
320
|
}
|
|
305
321
|
return s;
|
|
306
322
|
}).sort((a, b) => (a.model ?? "").localeCompare(b.model ?? ""));
|
|
307
|
-
|
|
308
|
-
|
|
323
|
+
return models;
|
|
324
|
+
}
|
|
325
|
+
function aggregateModels(records, options) {
|
|
326
|
+
const { requests: _requests, ...result } = analyzeModelRequests(records, options);
|
|
327
|
+
return result;
|
|
309
328
|
}
|
|
310
329
|
var nonnegative = (n) => n !== undefined && Number.isFinite(n) && n >= 0;
|
|
311
330
|
|
|
@@ -1433,8 +1452,32 @@ function buildChartData(records, options = {}) {
|
|
|
1433
1452
|
maxPoints
|
|
1434
1453
|
};
|
|
1435
1454
|
}
|
|
1455
|
+
// src/modelseries.ts
|
|
1456
|
+
function bucketModelRequests(requests, from, to, count) {
|
|
1457
|
+
if (!Number.isSafeInteger(from) || !Number.isSafeInteger(to) || from < 0 || from >= to || !Number.isSafeInteger(count) || count < 1 || count > 240)
|
|
1458
|
+
throw new Error("Invalid analytics buckets");
|
|
1459
|
+
const groups = Array.from({ length: count }, () => []);
|
|
1460
|
+
for (const request of requests) {
|
|
1461
|
+
if (request.completedAt < from || request.completedAt >= to)
|
|
1462
|
+
continue;
|
|
1463
|
+
const index = Math.min(count - 1, Math.floor((request.completedAt - from) / (to - from) * count));
|
|
1464
|
+
groups[index]?.push(request);
|
|
1465
|
+
}
|
|
1466
|
+
return groups.map((group, index) => {
|
|
1467
|
+
const summaries = summarizeModelRequests(group);
|
|
1468
|
+
if (summaries.length > 1)
|
|
1469
|
+
throw new Error("Select one model for buckets");
|
|
1470
|
+
const summary = summaries[0];
|
|
1471
|
+
return {
|
|
1472
|
+
from: from + (to - from) * index / count,
|
|
1473
|
+
to: from + (to - from) * (index + 1) / count,
|
|
1474
|
+
...summary ? { summary } : {}
|
|
1475
|
+
};
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1436
1478
|
export {
|
|
1437
1479
|
usableInput,
|
|
1480
|
+
summarizeModelRequests,
|
|
1438
1481
|
promptTokens,
|
|
1439
1482
|
project,
|
|
1440
1483
|
parseConfig,
|
|
@@ -1447,6 +1490,8 @@ export {
|
|
|
1447
1490
|
estimate,
|
|
1448
1491
|
downsamplePoints,
|
|
1449
1492
|
buildChartData,
|
|
1493
|
+
bucketModelRequests,
|
|
1494
|
+
analyzeModelRequests,
|
|
1450
1495
|
aggregateModels,
|
|
1451
1496
|
SnapshotStore,
|
|
1452
1497
|
PolicyResolver,
|