@openhoo/hoopilot 1.3.0 → 2.1.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 +67 -23
- package/dist/{chunk-JU6F5L34.js → chunk-6ALEIJJM.js} +82 -20
- package/dist/chunk-6ALEIJJM.js.map +1 -0
- package/dist/cli.js +394 -403
- package/dist/cli.js.map +1 -1
- package/dist/codexx.js +1 -1
- package/dist/index.d.ts +20 -6
- package/dist/index.js +410 -354
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-JU6F5L34.js.map +0 -1
- package/dist/index.cjs +0 -4653
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -388
package/dist/codexx.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -51,6 +51,8 @@ declare class MetricsRegistry {
|
|
|
51
51
|
* the shared upstream connection instead of draining it in the background.
|
|
52
52
|
*/
|
|
53
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;
|
|
54
56
|
|
|
55
57
|
type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
56
58
|
interface Logger {
|
|
@@ -79,8 +81,8 @@ interface HoopilotLoggerOptions {
|
|
|
79
81
|
base?: LogFields;
|
|
80
82
|
colorize?: boolean;
|
|
81
83
|
env?: NodeJS.ProcessEnv;
|
|
82
|
-
format?: LogFormat | string;
|
|
83
|
-
level?: LogLevel | string;
|
|
84
|
+
format?: LogFormat | (string & {});
|
|
85
|
+
level?: LogLevel | (string & {});
|
|
84
86
|
stream?: {
|
|
85
87
|
write(message: string): unknown;
|
|
86
88
|
};
|
|
@@ -103,11 +105,11 @@ interface HoopilotServerOptions extends CopilotAuthOptions {
|
|
|
103
105
|
apiKey?: string;
|
|
104
106
|
host?: string;
|
|
105
107
|
logger?: HoopilotLogger;
|
|
106
|
-
logFormat?: LogFormat | string;
|
|
107
|
-
logLevel?: LogLevel | string;
|
|
108
|
+
logFormat?: LogFormat | (string & {});
|
|
109
|
+
logLevel?: LogLevel | (string & {});
|
|
108
110
|
metrics?: MetricsRegistry;
|
|
109
111
|
port?: number;
|
|
110
|
-
streamingProxyMode?: StreamingProxyMode | string;
|
|
112
|
+
streamingProxyMode?: StreamingProxyMode | (string & {});
|
|
111
113
|
}
|
|
112
114
|
interface StartedHoopilotServer {
|
|
113
115
|
server: Bun.Server<undefined>;
|
|
@@ -239,6 +241,14 @@ interface MetricsSnapshot {
|
|
|
239
241
|
};
|
|
240
242
|
uptimeSeconds: number;
|
|
241
243
|
}
|
|
244
|
+
/** JSON body returned by the proxy's `/v1/usage` route. */
|
|
245
|
+
interface UsageResponseBody {
|
|
246
|
+
copilot: CopilotUsage | null;
|
|
247
|
+
copilot_error?: string;
|
|
248
|
+
object: "usage";
|
|
249
|
+
proxy: MetricsSnapshot;
|
|
250
|
+
version: string;
|
|
251
|
+
}
|
|
242
252
|
|
|
243
253
|
interface AnthropicStreamOptions {
|
|
244
254
|
model: string;
|
|
@@ -252,6 +262,7 @@ declare function responsesResponseToAnthropicMessage(response: JsonObject, fallb
|
|
|
252
262
|
declare function responsesStreamToAnthropicStream(stream: ReadableStream<Uint8Array>, options: AnthropicStreamOptions): ReadableStream<Uint8Array>;
|
|
253
263
|
declare function estimateAnthropicMessageTokens(request: JsonObject): JsonObject;
|
|
254
264
|
|
|
265
|
+
declare const DEFAULT_COPILOT_API_BASE_URL = "https://api.githubcopilot.com";
|
|
255
266
|
declare class CopilotAuthError extends Error {
|
|
256
267
|
constructor(message: string);
|
|
257
268
|
}
|
|
@@ -353,6 +364,9 @@ interface ResponseStreamOptions {
|
|
|
353
364
|
model: string;
|
|
354
365
|
responseId?: string;
|
|
355
366
|
}
|
|
367
|
+
declare class OpenAICompatibilityError extends Error {
|
|
368
|
+
constructor(message: string);
|
|
369
|
+
}
|
|
356
370
|
declare function responsesRequestToChatCompletion(request: JsonObject): JsonObject;
|
|
357
371
|
declare function normalizeChatCompletionRequest(request: JsonObject): JsonObject;
|
|
358
372
|
declare function completionsRequestToChatCompletion(request: JsonObject): JsonObject;
|
|
@@ -385,4 +399,4 @@ declare function extractTokenUsage(usage: unknown): TokenUsage | undefined;
|
|
|
385
399
|
declare function createHoopilotHandler(options?: HoopilotServerOptions): (request: Request) => Promise<Response>;
|
|
386
400
|
declare function startHoopilotServer(options?: HoopilotServerOptions): StartedHoopilotServer;
|
|
387
401
|
|
|
388
|
-
export { AnthropicCompatibilityError, COPILOT_USAGE_API_VERSION, type CopilotAccess, CopilotAuth, CopilotAuthError, type CopilotAuthOptions, CopilotClient, type CopilotQuota, type CopilotUsage, 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 LogFields, type LogFormat, type LogLevel, type LogMethod, type Logger, MetricsRegistry, type MetricsSnapshot, type ModelTokenTotals, PROMETHEUS_CONTENT_TYPE, type RequestObservation, type StartedHoopilotServer, type TokenUsage, anthropicMessagesToResponsesRequest, applyCopilotHeaders, applyGithubApiHeaders, authStorePath, chatCompletionToCompletion, chatCompletionToResponse, completionStreamFromChatStream, completionsRequestToChatCompletion, createHoopilotHandler, createHoopilotLogger, estimateAnthropicMessageTokens, extractTokenUsage, fallbackModels, githubCopilotDeviceLogin, noopLogger, normalizeChatCompletionRequest, normalizeCopilotUsage, normalizeModelsResponse, normalizeRequestedModel, observeResponseUsage, parseLogFormat, parseLogLevel, parseRateLimitHeaders, readStoredCopilotAuth, responsesCompactionResult, responsesRequestToChatCompletion, responsesResponseToAnthropicMessage, responsesStreamFromChatStream, responsesStreamToAnthropicStream, startHoopilotServer, writeStoredCopilotAuth };
|
|
402
|
+
export { AnthropicCompatibilityError, 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, OpenAICompatibilityError, PROMETHEUS_CONTENT_TYPE, type RequestObservation, type RouteLatency, type StartedHoopilotServer, type StreamingProxyMode, type TokenUsage, type UsageResponseBody, anthropicMessagesToResponsesRequest, applyCopilotHeaders, applyGithubApiHeaders, authStorePath, chatCompletionToCompletion, chatCompletionToResponse, completionStreamFromChatStream, completionsRequestToChatCompletion, createHoopilotHandler, createHoopilotLogger, estimateAnthropicMessageTokens, extractTokenUsage, fallbackModels, githubCopilotDeviceLogin, noopLogger, normalizeChatCompletionRequest, normalizeCopilotUsage, normalizeModelsResponse, normalizeRequestedModel, observeResponseUsage, parseLogFormat, parseLogLevel, parseRateLimitHeaders, readStoredCopilotAuth, recordResponseTextUsage, responsesCompactionResult, responsesRequestToChatCompletion, responsesResponseToAnthropicMessage, responsesStreamFromChatStream, responsesStreamToAnthropicStream, startHoopilotServer, writeStoredCopilotAuth };
|