@sema-agent/server 3.7.1 → 3.8.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/dist/budget.js
CHANGED
|
@@ -139,6 +139,12 @@ export function createTracer(metrics, costQuota, modelUsage, fleetUsage, fleetLe
|
|
|
139
139
|
if (principal)
|
|
140
140
|
costQuota?.add(principal, e.costMicroUsd);
|
|
141
141
|
}
|
|
142
|
+
else if (e.costMicroUsd === undefined) {
|
|
143
|
+
// D5:cost 整键缺席 = 未知(RB-368)——计数供 /metrics/summary 的 costUnknown/unpricedCalls
|
|
144
|
+
// 信号(costUsd 在 unpriced 部署恒 0,没有这个信号消费端会读成「零花费」)。显式 0 =
|
|
145
|
+
// declared free,走上面 truthy 为假的静默臂,不计入 unpriced。
|
|
146
|
+
metrics.inc("brain_calls_unpriced_total", { model: modelId(e.model) });
|
|
147
|
+
}
|
|
142
148
|
// ┌─ #59 裁定 / RB-368 结案([2052]① cli 报案 → [2073] 立案 → [2076] 工单挂 core → [2083] 到货) ─┐
|
|
143
149
|
// 病灶报案:下面三处曾是 `e.costMicroUsd ?? 0`(账本 + fleetUsage + fleetLease),把「成本未知」记成
|
|
144
150
|
// 「免费」,与 `pricingConfigured=false` 的部署组合 ⇒ 全部账目假 0。
|
|
@@ -34,6 +34,9 @@ export interface MetricsSummary {
|
|
|
34
34
|
tokensTotal: number;
|
|
35
35
|
costUsd: number;
|
|
36
36
|
costUsdByModel: Record<string, number>;
|
|
37
|
+
/** true ⇒ 窗口内有 cost 未知的 brain.call(unpriced 部署),costUsd/costUsdByModel 是下界(D5)。 */
|
|
38
|
+
costUnknown: boolean;
|
|
39
|
+
unpricedCalls: number;
|
|
37
40
|
taskDurationAvgSec: number | null;
|
|
38
41
|
brainFirstTokenAvgMs: number | null;
|
|
39
42
|
brainCallAvgMs: number | null;
|
|
@@ -163,6 +163,11 @@ export class Metrics {
|
|
|
163
163
|
tokensTotal: ctotal("task_tokens_total"),
|
|
164
164
|
costUsd: ctotal("model_cost_micro_usd_total") / 1e6,
|
|
165
165
|
costUsdByModel: Object.fromEntries(Object.entries(cby("model_cost_micro_usd_total", "model")).map(([k, v]) => [k, v / 1e6])),
|
|
166
|
+
// D5([2122] 挂账,additive v1):unpriced 部署下 costUsd 恒 0 而消费端读成「零花费」。
|
|
167
|
+
// costUnknown=true ⇒ costUsd/costUsdByModel 是**下界**(RB-368 缺席=未知语义;显式 0 = declared
|
|
168
|
+
// free 不计入 unpriced)。计数点在 budget.ts 的 brain.call 臂。
|
|
169
|
+
costUnknown: ctotal("brain_calls_unpriced_total") > 0,
|
|
170
|
+
unpricedCalls: ctotal("brain_calls_unpriced_total"),
|
|
166
171
|
taskDurationAvgSec: havg("task_duration_seconds"),
|
|
167
172
|
brainFirstTokenAvgMs: havg("brain_first_token_ms"),
|
|
168
173
|
brainCallAvgMs: havg("brain_call_latency_ms"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sema-agent/server",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Sema Server — the server/API implementation layer for Sema, wiring core, registry, model providers, and cloud agent execution. Built on @sema-agent/core.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "BUSL-1.1",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"dev:bake-runner": "tsx src/bake-runner/main.ts",
|
|
47
47
|
"test": "vitest run",
|
|
48
48
|
"test:db-integration": "vitest run integration",
|
|
49
|
+
"perf:baseline": "tsx scripts/perf-baseline.mjs",
|
|
49
50
|
"build:binary": "bun build --compile src/main.ts --outfile dist/sema-server",
|
|
50
51
|
"build:binary:linux-x64": "bun build --compile --target=bun-linux-x64 src/main.ts --outfile dist/sema-server-linux-x64",
|
|
51
52
|
"build:binary:darwin-arm64": "bun build --compile --target=bun-darwin-arm64 src/main.ts --outfile dist/sema-server-darwin-arm64",
|