oasis_test 0.1.46 → 0.1.47
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/dist/index.js +73 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -34362,7 +34362,7 @@ function priceForModel(model) {
|
|
|
34362
34362
|
function estimateRowCost(row) {
|
|
34363
34363
|
return estimateUsageCost(row.effectiveModel, row);
|
|
34364
34364
|
}
|
|
34365
|
-
function
|
|
34365
|
+
function estimateUsageCostBreakdown(model, usage) {
|
|
34366
34366
|
const price = priceForModel(model);
|
|
34367
34367
|
if (!price) return null;
|
|
34368
34368
|
const inputTokens = Math.max(usage.inputTokens ?? 0, 0);
|
|
@@ -34370,8 +34370,22 @@ function estimateUsageCost(model, usage) {
|
|
|
34370
34370
|
const cacheReadTokens = Math.max(usage.cacheReadTokens ?? 0, 0);
|
|
34371
34371
|
const cacheCreationTokens = Math.max(usage.cacheCreationTokens ?? 0, 0);
|
|
34372
34372
|
const cacheReadPrice = price.cachedInputPerMillion ?? price.inputPerMillion * 0.1;
|
|
34373
|
-
|
|
34374
|
-
|
|
34373
|
+
return {
|
|
34374
|
+
currency: price.currency,
|
|
34375
|
+
inputMicros: Math.round(inputTokens * price.inputPerMillion / 1e6 * 1e6),
|
|
34376
|
+
cacheMicros: Math.round(
|
|
34377
|
+
(cacheCreationTokens * price.inputPerMillion + cacheReadTokens * cacheReadPrice) / 1e6 * 1e6
|
|
34378
|
+
),
|
|
34379
|
+
outputMicros: Math.round(outputTokens * price.outputPerMillion / 1e6 * 1e6)
|
|
34380
|
+
};
|
|
34381
|
+
}
|
|
34382
|
+
function estimateUsageCost(model, usage) {
|
|
34383
|
+
const breakdown = estimateUsageCostBreakdown(model, usage);
|
|
34384
|
+
if (!breakdown) return null;
|
|
34385
|
+
return {
|
|
34386
|
+
currency: breakdown.currency,
|
|
34387
|
+
micros: breakdown.inputMicros + breakdown.cacheMicros + breakdown.outputMicros
|
|
34388
|
+
};
|
|
34375
34389
|
}
|
|
34376
34390
|
var FOREIGN_MODEL_MARKUP, usd, cny, MODEL_PRICES, PREFIX_PRICES;
|
|
34377
34391
|
var init_model_pricing = __esm({
|
|
@@ -34486,6 +34500,30 @@ var init_model_pricing = __esm({
|
|
|
34486
34500
|
});
|
|
34487
34501
|
|
|
34488
34502
|
// ../server/src/domains/actors/stats.ts
|
|
34503
|
+
function emptyCostBreakdown() {
|
|
34504
|
+
return {
|
|
34505
|
+
inputUsdMicros: 0,
|
|
34506
|
+
cacheUsdMicros: 0,
|
|
34507
|
+
outputUsdMicros: 0,
|
|
34508
|
+
inputCnyMicros: 0,
|
|
34509
|
+
cacheCnyMicros: 0,
|
|
34510
|
+
outputCnyMicros: 0
|
|
34511
|
+
};
|
|
34512
|
+
}
|
|
34513
|
+
function addEstimatedBreakdown(target, model, usage) {
|
|
34514
|
+
const estimated = estimateUsageCostBreakdown(model, usage);
|
|
34515
|
+
if (!estimated) return false;
|
|
34516
|
+
if (estimated.currency === "USD") {
|
|
34517
|
+
target.inputUsdMicros += estimated.inputMicros;
|
|
34518
|
+
target.cacheUsdMicros += estimated.cacheMicros;
|
|
34519
|
+
target.outputUsdMicros += estimated.outputMicros;
|
|
34520
|
+
} else {
|
|
34521
|
+
target.inputCnyMicros += estimated.inputMicros;
|
|
34522
|
+
target.cacheCnyMicros += estimated.cacheMicros;
|
|
34523
|
+
target.outputCnyMicros += estimated.outputMicros;
|
|
34524
|
+
}
|
|
34525
|
+
return true;
|
|
34526
|
+
}
|
|
34489
34527
|
async function actorStats(oplog, actorId, opts = {}) {
|
|
34490
34528
|
const myRevisions = /* @__PURE__ */ new Set();
|
|
34491
34529
|
const mergedTargets = /* @__PURE__ */ new Set();
|
|
@@ -34529,8 +34567,10 @@ async function actorStats(oplog, actorId, opts = {}) {
|
|
|
34529
34567
|
approveRateGiven: reviewsGiven === 0 ? null : approvalsGiven / reviewsGiven,
|
|
34530
34568
|
reworkReceived,
|
|
34531
34569
|
tokenWeek: weeklyUsage.tokenWeek,
|
|
34570
|
+
tokenWeekBreakdown: weeklyUsage.tokenWeekBreakdown,
|
|
34532
34571
|
costWeekUsdMicros: weeklyUsage.costWeekUsdMicros,
|
|
34533
34572
|
costWeekCnyMicros: weeklyUsage.costWeekCnyMicros,
|
|
34573
|
+
costWeekBreakdown: weeklyUsage.costWeekBreakdown,
|
|
34534
34574
|
usageWindow: { from, to },
|
|
34535
34575
|
unpricedModels: weeklyUsage.unpricedModels
|
|
34536
34576
|
};
|
|
@@ -34546,18 +34586,24 @@ async function listWeeklyRuns(trace, actorId, from, to) {
|
|
|
34546
34586
|
return out;
|
|
34547
34587
|
}
|
|
34548
34588
|
function summarizeWeeklyRuns(runs) {
|
|
34549
|
-
let
|
|
34589
|
+
let input = 0;
|
|
34590
|
+
let cache = 0;
|
|
34591
|
+
let output = 0;
|
|
34550
34592
|
let costWeekUsdMicros = 0;
|
|
34551
34593
|
let costWeekCnyMicros = 0;
|
|
34594
|
+
const costWeekBreakdown = emptyCostBreakdown();
|
|
34552
34595
|
const unpriced = /* @__PURE__ */ new Set();
|
|
34553
34596
|
for (const run of runs) {
|
|
34554
34597
|
const usage = run.usage;
|
|
34555
34598
|
if (!usage) continue;
|
|
34556
|
-
const
|
|
34557
|
-
const
|
|
34599
|
+
const inputTokens = Math.max(usage.inputTokens ?? 0, 0);
|
|
34600
|
+
const outputTokens = Math.max(usage.outputTokens ?? 0, 0);
|
|
34558
34601
|
const cacheCreation = Math.max(usage.cacheCreationTokens ?? 0, 0);
|
|
34559
34602
|
const cacheRead = Math.max(usage.cacheReadTokens ?? 0, 0);
|
|
34560
|
-
|
|
34603
|
+
input += inputTokens;
|
|
34604
|
+
cache += cacheCreation + cacheRead;
|
|
34605
|
+
output += outputTokens;
|
|
34606
|
+
const priced = addEstimatedBreakdown(costWeekBreakdown, run.effectiveModel ?? null, usage);
|
|
34561
34607
|
const storedCost = Math.max(usage.costUsdMicros ?? 0, 0);
|
|
34562
34608
|
if (storedCost > 0) {
|
|
34563
34609
|
costWeekUsdMicros += storedCost;
|
|
@@ -34569,28 +34615,36 @@ function summarizeWeeklyRuns(runs) {
|
|
|
34569
34615
|
else costWeekCnyMicros += estimated.micros;
|
|
34570
34616
|
continue;
|
|
34571
34617
|
}
|
|
34572
|
-
if (
|
|
34618
|
+
if (!priced && inputTokens + outputTokens + cacheCreation + cacheRead > 0) {
|
|
34573
34619
|
unpriced.add(run.effectiveModel ?? "unknown");
|
|
34574
34620
|
}
|
|
34575
34621
|
}
|
|
34576
34622
|
return {
|
|
34577
|
-
tokenWeek,
|
|
34623
|
+
tokenWeek: input + cache + output,
|
|
34624
|
+
tokenWeekBreakdown: { input, cache, output },
|
|
34578
34625
|
costWeekUsdMicros,
|
|
34579
34626
|
costWeekCnyMicros,
|
|
34627
|
+
costWeekBreakdown,
|
|
34580
34628
|
unpricedModels: [...unpriced].sort()
|
|
34581
34629
|
};
|
|
34582
34630
|
}
|
|
34583
34631
|
function summarizeWeeklyUsage(rows) {
|
|
34584
|
-
let
|
|
34632
|
+
let input = 0;
|
|
34633
|
+
let cache = 0;
|
|
34634
|
+
let output = 0;
|
|
34585
34635
|
let costWeekUsdMicros = 0;
|
|
34586
34636
|
let costWeekCnyMicros = 0;
|
|
34637
|
+
const costWeekBreakdown = emptyCostBreakdown();
|
|
34587
34638
|
const unpriced = /* @__PURE__ */ new Set();
|
|
34588
34639
|
for (const row of rows) {
|
|
34589
|
-
const
|
|
34590
|
-
const
|
|
34640
|
+
const inputTokens = Math.max(row.inputTokens, 0);
|
|
34641
|
+
const outputTokens = Math.max(row.outputTokens, 0);
|
|
34591
34642
|
const cacheCreation = Math.max(row.cacheCreationTokens, 0);
|
|
34592
34643
|
const cacheRead = Math.max(row.cacheReadTokens, 0);
|
|
34593
|
-
|
|
34644
|
+
input += inputTokens;
|
|
34645
|
+
cache += cacheCreation + cacheRead;
|
|
34646
|
+
output += outputTokens;
|
|
34647
|
+
const priced = addEstimatedBreakdown(costWeekBreakdown, row.effectiveModel, row);
|
|
34594
34648
|
const storedCost = Math.max(row.costUsdMicros, 0);
|
|
34595
34649
|
if (storedCost > 0) {
|
|
34596
34650
|
costWeekUsdMicros += storedCost;
|
|
@@ -34602,14 +34656,16 @@ function summarizeWeeklyUsage(rows) {
|
|
|
34602
34656
|
else costWeekCnyMicros += estimated.micros;
|
|
34603
34657
|
continue;
|
|
34604
34658
|
}
|
|
34605
|
-
if (
|
|
34659
|
+
if (!priced && inputTokens + outputTokens + cacheCreation + cacheRead > 0) {
|
|
34606
34660
|
unpriced.add(row.effectiveModel ?? "unknown");
|
|
34607
34661
|
}
|
|
34608
34662
|
}
|
|
34609
34663
|
return {
|
|
34610
|
-
tokenWeek,
|
|
34664
|
+
tokenWeek: input + cache + output,
|
|
34665
|
+
tokenWeekBreakdown: { input, cache, output },
|
|
34611
34666
|
costWeekUsdMicros,
|
|
34612
34667
|
costWeekCnyMicros,
|
|
34668
|
+
costWeekBreakdown,
|
|
34613
34669
|
unpricedModels: [...unpriced].sort()
|
|
34614
34670
|
};
|
|
34615
34671
|
}
|
|
@@ -40734,7 +40790,7 @@ Write-Host " Remove : Unregister-ScheduledTask -TaskName 'OasisNode' -Confirm:$
|
|
|
40734
40790
|
}
|
|
40735
40791
|
function buildNpxCmd(p2) {
|
|
40736
40792
|
const namePart = p2.nodeName ? ` --name ${p2.nodeName}` : "";
|
|
40737
|
-
return `
|
|
40793
|
+
return `npm install -g --prefer-online --prefix ~/.oasis/npm-global oasis_test@latest && ~/.oasis/npm-global/bin/oasis start --server-ws ${p2.gatewayUrl}${namePart} --enroll-token ${p2.token}`;
|
|
40738
40794
|
}
|
|
40739
40795
|
var init_connect_script = __esm({
|
|
40740
40796
|
"../server/src/domains/nodes/connect-script.ts"() {
|
|
@@ -58645,7 +58701,7 @@ ${res.warning}`);
|
|
|
58645
58701
|
}
|
|
58646
58702
|
|
|
58647
58703
|
// src/index.ts
|
|
58648
|
-
var PKG_VERSION = true ? "0.1.
|
|
58704
|
+
var PKG_VERSION = true ? "0.1.47" : "dev";
|
|
58649
58705
|
var OASIS_DIR = path19.join(os11.homedir(), ".oasis");
|
|
58650
58706
|
var CONFIG_FILE = path19.join(OASIS_DIR, "node-config.json");
|
|
58651
58707
|
var PID_FILE = path19.join(OASIS_DIR, "node.pid");
|