oc2token 0.1.7 → 0.1.8
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/package.json
CHANGED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { type UsageWindow } from "./windows.js";
|
|
2
|
-
/**
|
|
3
|
-
* The smallest shape needed to measure generation throughput. `UsageRecord`
|
|
4
|
-
* satisfies this structurally, so one pure function serves both domain tests
|
|
5
|
-
* and the renderer's leniently-extracted observations.
|
|
6
|
-
*/
|
|
7
|
-
export interface RateObservation {
|
|
8
|
-
readonly createdAt: Date;
|
|
9
|
-
readonly completedAt?: Date;
|
|
10
|
-
readonly output: number;
|
|
11
|
-
readonly reasoning: number;
|
|
12
|
-
readonly completeness: "final" | "provisional";
|
|
13
|
-
}
|
|
14
|
-
export interface GenerationRate {
|
|
15
|
-
readonly tokensPerSecond: number;
|
|
16
|
-
readonly measuredRequests: number;
|
|
17
|
-
readonly totalTokens: number;
|
|
18
|
-
readonly totalDurationMs: number;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Durations below this are measurement noise, not generation time. A 1 ms
|
|
22
|
-
* duration with 500 output tokens would otherwise contribute 500,000 tok/s
|
|
23
|
-
* to the aggregate and dominate every real request in the window.
|
|
24
|
-
*/
|
|
25
|
-
export declare const MIN_MEASURED_DURATION_MS = 100;
|
|
26
|
-
export interface GenerationRateOptions {
|
|
27
|
-
/** Provisional messages are excluded by default, matching sumUsageRecords. */
|
|
28
|
-
readonly includeProvisional?: boolean;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Average generation throughput over a window, as a duration-weighted ratio:
|
|
32
|
-
* total streamed tokens divided by total measured wall time.
|
|
33
|
-
*
|
|
34
|
-
* This is the pooled ratio, not a mean of per-request rates. Averaging the
|
|
35
|
-
* ratios would let a single 2-second request outweigh a 60-second one; the
|
|
36
|
-
* pooled form weights each request by how long it actually ran.
|
|
37
|
-
*
|
|
38
|
-
* A record contributes only when it is final (unless opted in), inside the
|
|
39
|
-
* window, and has a `completedAt` at least {@link MIN_MEASURED_DURATION_MS}
|
|
40
|
-
* after `createdAt`. Providers without latency data (Codex, Antigravity)
|
|
41
|
-
* simply never contribute, so their windows return `undefined` rather than a
|
|
42
|
-
* fabricated number. Returns `undefined` when nothing qualifies — absence is
|
|
43
|
-
* not zero.
|
|
44
|
-
*/
|
|
45
|
-
export declare function generationRate(observations: ReadonlyArray<RateObservation>, window: UsageWindow, options?: GenerationRateOptions): GenerationRate | undefined;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rate.js","sourceRoot":"","sources":["../../../src/domain/rate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAoB,MAAM,cAAc,CAAC;AAsBjE;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAO5C;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,cAAc,CAC5B,YAA4C,EAC5C,MAAmB,EACnB,UAAiC,EAAE;IAEnC,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,eAAe,GAAG,CAAC,CAAC;IACxB,IAAI,gBAAgB,GAAG,CAAC,CAAC;IAEzB,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,IAAI,WAAW,CAAC,YAAY,KAAK,aAAa,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;YAC9E,SAAS;QACX,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;YACpD,SAAS;QACX,CAAC;QACD,MAAM,WAAW,GAAG,WAAW,CAAC,WAAW,CAAC;QAC5C,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,SAAS;QACX,CAAC;QACD,MAAM,UAAU,GAAG,WAAW,CAAC,OAAO,EAAE,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