@openhoo/hoopilot 1.1.0 → 1.3.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/README.md +9 -1
- package/dist/cli.js +970 -27
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +989 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -1
- package/dist/index.d.ts +30 -1
- package/dist/index.js +988 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -15,6 +15,13 @@ declare class MetricsRegistry {
|
|
|
15
15
|
startRequest(): void;
|
|
16
16
|
/** Record a completed request and clear its in-flight slot. */
|
|
17
17
|
observe(observation: RequestObservation): void;
|
|
18
|
+
/**
|
|
19
|
+
* Record whether one upstream completion reported token usage. `missing`
|
|
20
|
+
* counts responses that carried no usage object — most often streamed Chat
|
|
21
|
+
* Completions sent without `stream_options: {"include_usage": true}` — so a
|
|
22
|
+
* rising miss rate flags clients whose token usage is going unaccounted.
|
|
23
|
+
*/
|
|
24
|
+
recordTokenExtraction(extracted: boolean): void;
|
|
18
25
|
/** Accumulate token counts for a model from one upstream completion. */
|
|
19
26
|
recordTokens(model: string, usage: TokenUsage): void;
|
|
20
27
|
/** Record one upstream Copilot call and whether it succeeded. */
|
|
@@ -43,7 +50,7 @@ declare class MetricsRegistry {
|
|
|
43
50
|
* branch; combined with the runtime cancelling the client branch, that releases
|
|
44
51
|
* the shared upstream connection instead of draining it in the background.
|
|
45
52
|
*/
|
|
46
|
-
declare function observeResponseUsage(response: Response, fallbackModel: string, onUsage: (model: string, usage: TokenUsage) => void, signal?: AbortSignal): Response;
|
|
53
|
+
declare function observeResponseUsage(response: Response, fallbackModel: string, onUsage: (model: string, usage: TokenUsage) => void, signal?: AbortSignal, onOutcome?: (extracted: boolean) => void): Response;
|
|
47
54
|
|
|
48
55
|
type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
49
56
|
interface Logger {
|
|
@@ -186,10 +193,28 @@ interface GithubRateLimitSnapshot {
|
|
|
186
193
|
retryAfterSeconds?: number;
|
|
187
194
|
used?: number;
|
|
188
195
|
}
|
|
196
|
+
/** Request-latency summary for one route, in milliseconds. */
|
|
197
|
+
interface RouteLatency {
|
|
198
|
+
avgMs: number;
|
|
199
|
+
count: number;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Aggregate request-latency summary derived from the duration histogram. `avgMs`
|
|
203
|
+
* is exact; the percentiles are estimated from the histogram buckets (Prometheus-
|
|
204
|
+
* style linear interpolation), so they are approximate.
|
|
205
|
+
*/
|
|
206
|
+
interface LatencySnapshot {
|
|
207
|
+
avgMs: number;
|
|
208
|
+
byRoute: Record<string, RouteLatency>;
|
|
209
|
+
count: number;
|
|
210
|
+
p50Ms: number;
|
|
211
|
+
p95Ms: number;
|
|
212
|
+
}
|
|
189
213
|
/** A point-in-time JSON view of the in-process metrics. */
|
|
190
214
|
interface MetricsSnapshot {
|
|
191
215
|
githubRateLimit: Record<string, GithubRateLimitSnapshot>;
|
|
192
216
|
inFlight: number;
|
|
217
|
+
latency: LatencySnapshot;
|
|
193
218
|
requests: {
|
|
194
219
|
byRoute: Record<string, number>;
|
|
195
220
|
byStatus: Record<string, number>;
|
|
@@ -200,6 +225,10 @@ interface MetricsSnapshot {
|
|
|
200
225
|
byModel: Record<string, ModelTokenTotals>;
|
|
201
226
|
cached: number;
|
|
202
227
|
completion: number;
|
|
228
|
+
extraction: {
|
|
229
|
+
extracted: number;
|
|
230
|
+
missing: number;
|
|
231
|
+
};
|
|
203
232
|
prompt: number;
|
|
204
233
|
reasoning: number;
|
|
205
234
|
total: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,13 @@ declare class MetricsRegistry {
|
|
|
15
15
|
startRequest(): void;
|
|
16
16
|
/** Record a completed request and clear its in-flight slot. */
|
|
17
17
|
observe(observation: RequestObservation): void;
|
|
18
|
+
/**
|
|
19
|
+
* Record whether one upstream completion reported token usage. `missing`
|
|
20
|
+
* counts responses that carried no usage object — most often streamed Chat
|
|
21
|
+
* Completions sent without `stream_options: {"include_usage": true}` — so a
|
|
22
|
+
* rising miss rate flags clients whose token usage is going unaccounted.
|
|
23
|
+
*/
|
|
24
|
+
recordTokenExtraction(extracted: boolean): void;
|
|
18
25
|
/** Accumulate token counts for a model from one upstream completion. */
|
|
19
26
|
recordTokens(model: string, usage: TokenUsage): void;
|
|
20
27
|
/** Record one upstream Copilot call and whether it succeeded. */
|
|
@@ -43,7 +50,7 @@ declare class MetricsRegistry {
|
|
|
43
50
|
* branch; combined with the runtime cancelling the client branch, that releases
|
|
44
51
|
* the shared upstream connection instead of draining it in the background.
|
|
45
52
|
*/
|
|
46
|
-
declare function observeResponseUsage(response: Response, fallbackModel: string, onUsage: (model: string, usage: TokenUsage) => void, signal?: AbortSignal): Response;
|
|
53
|
+
declare function observeResponseUsage(response: Response, fallbackModel: string, onUsage: (model: string, usage: TokenUsage) => void, signal?: AbortSignal, onOutcome?: (extracted: boolean) => void): Response;
|
|
47
54
|
|
|
48
55
|
type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
49
56
|
interface Logger {
|
|
@@ -186,10 +193,28 @@ interface GithubRateLimitSnapshot {
|
|
|
186
193
|
retryAfterSeconds?: number;
|
|
187
194
|
used?: number;
|
|
188
195
|
}
|
|
196
|
+
/** Request-latency summary for one route, in milliseconds. */
|
|
197
|
+
interface RouteLatency {
|
|
198
|
+
avgMs: number;
|
|
199
|
+
count: number;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Aggregate request-latency summary derived from the duration histogram. `avgMs`
|
|
203
|
+
* is exact; the percentiles are estimated from the histogram buckets (Prometheus-
|
|
204
|
+
* style linear interpolation), so they are approximate.
|
|
205
|
+
*/
|
|
206
|
+
interface LatencySnapshot {
|
|
207
|
+
avgMs: number;
|
|
208
|
+
byRoute: Record<string, RouteLatency>;
|
|
209
|
+
count: number;
|
|
210
|
+
p50Ms: number;
|
|
211
|
+
p95Ms: number;
|
|
212
|
+
}
|
|
189
213
|
/** A point-in-time JSON view of the in-process metrics. */
|
|
190
214
|
interface MetricsSnapshot {
|
|
191
215
|
githubRateLimit: Record<string, GithubRateLimitSnapshot>;
|
|
192
216
|
inFlight: number;
|
|
217
|
+
latency: LatencySnapshot;
|
|
193
218
|
requests: {
|
|
194
219
|
byRoute: Record<string, number>;
|
|
195
220
|
byStatus: Record<string, number>;
|
|
@@ -200,6 +225,10 @@ interface MetricsSnapshot {
|
|
|
200
225
|
byModel: Record<string, ModelTokenTotals>;
|
|
201
226
|
cached: number;
|
|
202
227
|
completion: number;
|
|
228
|
+
extraction: {
|
|
229
|
+
extracted: number;
|
|
230
|
+
missing: number;
|
|
231
|
+
};
|
|
203
232
|
prompt: number;
|
|
204
233
|
reasoning: number;
|
|
205
234
|
total: number;
|