@openhoo/hoopilot 2.1.6 → 2.1.7
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 +79 -4
- package/dist/{chunk-4ZG5QEYJ.js → chunk-2GLKVNAA.js} +5 -2
- package/dist/chunk-2GLKVNAA.js.map +1 -0
- package/dist/cli.js +407 -407
- package/dist/cli.js.map +1 -1
- package/dist/codexx.js +1 -1
- package/dist/index.d.ts +4 -64
- package/dist/index.js +2699 -3191
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-4ZG5QEYJ.js.map +0 -1
package/dist/codexx.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -39,20 +39,6 @@ declare class MetricsRegistry {
|
|
|
39
39
|
/** Render the Prometheus text exposition format (version 0.0.4). */
|
|
40
40
|
renderPrometheus(now?: () => number): string;
|
|
41
41
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Wrap `response`'s body so the client receives unchanged bytes while the same
|
|
44
|
-
* read pass extracts token usage. Returns a new Response carrying the observed
|
|
45
|
-
* body and the original status/headers. Usage extraction never throws into the
|
|
46
|
-
* client stream: a parse failure or an aborted client simply yields no usage.
|
|
47
|
-
* When the body is absent the response is returned untouched.
|
|
48
|
-
*
|
|
49
|
-
* Pass the request's `signal` so a client disconnect cancels the observer
|
|
50
|
-
* branch; combined with the runtime cancelling the client branch, that releases
|
|
51
|
-
* the shared upstream connection instead of draining it in the background.
|
|
52
|
-
*/
|
|
53
|
-
declare function observeResponseUsage(response: Response, fallbackModel: string, onUsage: (model: string, usage: TokenUsage) => void, signal?: AbortSignal, onOutcome?: (extracted: boolean) => void): Response;
|
|
54
|
-
/** Extract and record token usage from an already-buffered response body. */
|
|
55
|
-
declare function recordResponseTextUsage(text: string, isSse: boolean, fallbackModel: string, onUsage: (model: string, usage: TokenUsage) => void, onOutcome?: (extracted: boolean) => void): void;
|
|
56
42
|
|
|
57
43
|
type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
58
44
|
interface Logger {
|
|
@@ -258,18 +244,6 @@ interface UsageResponseBody {
|
|
|
258
244
|
version: string;
|
|
259
245
|
}
|
|
260
246
|
|
|
261
|
-
interface AnthropicStreamOptions {
|
|
262
|
-
model: string;
|
|
263
|
-
messageId?: string;
|
|
264
|
-
}
|
|
265
|
-
declare class AnthropicCompatibilityError extends Error {
|
|
266
|
-
constructor(message: string);
|
|
267
|
-
}
|
|
268
|
-
declare function anthropicMessagesToResponsesRequest(request: JsonObject): JsonObject;
|
|
269
|
-
declare function responsesResponseToAnthropicMessage(response: JsonObject, fallbackModel: string): JsonObject;
|
|
270
|
-
declare function responsesStreamToAnthropicStream(stream: ReadableStream<Uint8Array>, options: AnthropicStreamOptions): ReadableStream<Uint8Array>;
|
|
271
|
-
declare function estimateAnthropicMessageTokens(request: JsonObject): JsonObject;
|
|
272
|
-
|
|
273
247
|
declare const DEFAULT_COPILOT_API_BASE_URL = "https://api.githubcopilot.com";
|
|
274
248
|
declare class CopilotAuthError extends Error {
|
|
275
249
|
constructor(message: string);
|
|
@@ -345,6 +319,9 @@ declare class CopilotClient {
|
|
|
345
319
|
*/
|
|
346
320
|
declare function normalizeCopilotUsage(body: unknown): CopilotUsage;
|
|
347
321
|
|
|
322
|
+
/** Default model Hoopilot uses when a client does not supply one. */
|
|
323
|
+
declare const DEFAULT_MODEL = "gpt-5.5";
|
|
324
|
+
|
|
348
325
|
interface GithubCopilotDeviceLoginOptions {
|
|
349
326
|
clientId?: string;
|
|
350
327
|
domain?: string;
|
|
@@ -367,44 +344,7 @@ declare function createHoopilotLogger(options?: HoopilotLoggerOptions): Hoopilot
|
|
|
367
344
|
declare function parseLogFormat(value: string | undefined): LogFormat;
|
|
368
345
|
declare function parseLogLevel(value: string | undefined): LogLevel;
|
|
369
346
|
|
|
370
|
-
declare const DEFAULT_MODEL = "gpt-4.1";
|
|
371
|
-
interface ResponseStreamOptions {
|
|
372
|
-
model: string;
|
|
373
|
-
responseId?: string;
|
|
374
|
-
}
|
|
375
|
-
declare class OpenAICompatibilityError extends Error {
|
|
376
|
-
constructor(message: string);
|
|
377
|
-
}
|
|
378
|
-
declare function responsesRequestToChatCompletion(request: JsonObject): JsonObject;
|
|
379
|
-
declare function normalizeChatCompletionRequest(request: JsonObject): JsonObject;
|
|
380
|
-
declare function completionsRequestToChatCompletion(request: JsonObject): JsonObject;
|
|
381
|
-
declare function normalizeRequestedModel(model: unknown): string;
|
|
382
|
-
declare function chatCompletionToResponse(completion: JsonObject, responseId?: string): JsonObject;
|
|
383
|
-
/**
|
|
384
|
-
* Reduce a Copilot `/responses` result into the `{ output }` document Codex's
|
|
385
|
-
* remote-compaction client (`POST /responses/compact`) deserializes. Codex keeps
|
|
386
|
-
* only assistant/user message items from `output` and discards everything else,
|
|
387
|
-
* so a Responses `output` array passes through verbatim; when the upstream only
|
|
388
|
-
* exposes `output_text` (or, for a stream it did not honor `stream: false` on,
|
|
389
|
-
* `output_text` deltas) a single assistant message is synthesized instead. The
|
|
390
|
-
* input may be a unary JSON body or an SSE stream, so both framings are handled.
|
|
391
|
-
*/
|
|
392
|
-
declare function responsesCompactionResult(upstreamText: string, isSse: boolean): JsonObject;
|
|
393
|
-
declare function chatCompletionToCompletion(completion: JsonObject): JsonObject;
|
|
394
|
-
declare function completionStreamFromChatStream(chatStream: ReadableStream<Uint8Array>): ReadableStream<Uint8Array>;
|
|
395
|
-
declare function normalizeModelsResponse(upstream: unknown): JsonObject;
|
|
396
|
-
declare function fallbackModels(): Array<JsonObject>;
|
|
397
|
-
declare function responsesStreamFromChatStream(chatStream: ReadableStream<Uint8Array>, options: ResponseStreamOptions): ReadableStream<Uint8Array>;
|
|
398
|
-
/**
|
|
399
|
-
* Normalize an upstream `usage` object into {@link TokenUsage}. Accepts both the
|
|
400
|
-
* Chat Completions shape (`prompt_tokens`/`completion_tokens`) and the Responses
|
|
401
|
-
* shape (`input_tokens`/`output_tokens`), and pulls nested reasoning/cached
|
|
402
|
-
* details when present. Returns undefined when no token counts are available so
|
|
403
|
-
* callers can distinguish "no usage reported" from "zero tokens".
|
|
404
|
-
*/
|
|
405
|
-
declare function extractTokenUsage(usage: unknown): TokenUsage | undefined;
|
|
406
|
-
|
|
407
347
|
declare function createHoopilotHandler(options?: HoopilotServerOptions): (request: Request) => Promise<Response>;
|
|
408
348
|
declare function startHoopilotServer(options?: HoopilotServerOptions): StartedHoopilotServer;
|
|
409
349
|
|
|
410
|
-
export {
|
|
350
|
+
export { COPILOT_USAGE_API_VERSION, type CopilotAccess, CopilotAuth, CopilotAuthError, type CopilotAuthOptions, CopilotClient, type CopilotQuota, type CopilotUsage, DEFAULT_COPILOT_API_BASE_URL, DEFAULT_GITHUB_API_BASE_URL, DEFAULT_LOG_FORMAT, DEFAULT_LOG_LEVEL, DEFAULT_MODEL, type FetchLike, type GithubRateLimit, type GithubRateLimitSnapshot, type HoopilotLogger, type HoopilotLoggerOptions, type HoopilotServerOptions, type JsonObject, type LatencySnapshot, type LogFields, type LogFormat, type LogLevel, type LogMethod, type Logger, MetricsRegistry, type MetricsSnapshot, type ModelTokenTotals, PROMETHEUS_CONTENT_TYPE, type RequestObservation, type RouteLatency, type StartedHoopilotServer, type StreamingProxyMode, type TokenUsage, type UsageResponseBody, applyCopilotHeaders, applyGithubApiHeaders, authStorePath, createHoopilotHandler, createHoopilotLogger, githubCopilotDeviceLogin, noopLogger, normalizeCopilotUsage, parseLogFormat, parseLogLevel, parseRateLimitHeaders, readStoredCopilotAuth, startHoopilotServer, writeStoredCopilotAuth };
|