@caeliq/llms 1.0.61 → 1.0.63
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/cjs/server.cjs +178 -170
- package/dist/cjs/server.cjs.map +4 -4
- package/dist/esm/server.mjs +180 -172
- package/dist/esm/server.mjs.map +4 -4
- package/dist/server.d.ts +5 -1
- package/dist/tests/oauth-refresh-singleflight.d.ts +1 -0
- package/dist/tests/sse.done-boundary.d.ts +1 -0
- package/dist/transformer/opencode-headers.transformer.d.ts +6 -0
- package/dist/utils/claude-auth.d.ts +3 -1
- package/dist/utils/qwen-auth.d.ts +5 -2
- package/dist/utils/sse/done-boundary.d.ts +25 -0
- package/dist/utils/sse/index.d.ts +1 -0
- package/package.json +2 -2
package/dist/server.d.ts
CHANGED
|
@@ -57,7 +57,11 @@ export { pluginManager, tokenSpeedPlugin, getTokenSpeedStats, getGlobalTokenSpee
|
|
|
57
57
|
export { SSEParserTransform, SSESerializerTransform, rewriteStream } from "./utils/sse";
|
|
58
58
|
export { isClientAbortError } from "./utils/retry";
|
|
59
59
|
export { sanitizeHeadersForLog, diffHeadersForLog, sanitizeBodyForLog, DEFAULT_LOG_BODY_MAX_BYTES, } from "./utils/redact";
|
|
60
|
-
export { exchangeAuthorizationCode, fetchUserEmail, resolveProjectId, saveTokens, loadTokens, getValidAccessToken, ANTIGRAVITY_CLIENT_ID, ANTIGRAVITY_CLIENT_SECRET, ANTIGRAVITY_REDIRECT_URI, ANTIGRAVITY_SCOPES, type AntigravityTokens, } from "./utils/antigravity-auth";
|
|
60
|
+
export { exchangeAuthorizationCode, fetchUserEmail, resolveProjectId, saveTokens, loadTokens, getValidAccessToken, getValidAccessToken as getAntigravityAccessToken, ANTIGRAVITY_CLIENT_ID, ANTIGRAVITY_CLIENT_SECRET, ANTIGRAVITY_REDIRECT_URI, ANTIGRAVITY_SCOPES, type AntigravityTokens, } from "./utils/antigravity-auth";
|
|
61
|
+
export { getValidAccessToken as getClaudeAccessToken } from "./utils/claude-auth";
|
|
62
|
+
export { getValidAccessToken as getCodexAccessToken, } from "./utils/codex-auth";
|
|
63
|
+
export { getValidAccessToken as getQwenAccessToken } from "./utils/qwen-auth";
|
|
64
|
+
export { getValidAccessToken as getXaiAccessToken } from "./utils/xai-auth";
|
|
61
65
|
export { matchClientProtocol, isRoutedLlmPost, listClientRouteRegistrations, type ClientProtocol, type ClientProtocolContext, type ProtocolRouteMatch, } from "./routing/protocol-endpoints";
|
|
62
66
|
export { protocolErrorBody } from "./routing/protocol-errors";
|
|
63
67
|
export { setHealthReporter } from "./utils/health-reporter";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,6 +6,7 @@ export declare class OpencodeHeadersTransformer implements Transformer {
|
|
|
6
6
|
private lastTimestamp;
|
|
7
7
|
private counter;
|
|
8
8
|
transformRequestIn(request: any, provider: any, context: any): Promise<Record<string, any>>;
|
|
9
|
+
transformResponseOut(response: Response): Promise<Response>;
|
|
9
10
|
/**
|
|
10
11
|
* Own the full upstream call so a `No provider available` 401 can be retried
|
|
11
12
|
* with a fresh session in isolation. Any other non-ok response is re-thrown in
|
|
@@ -14,6 +15,8 @@ export declare class OpencodeHeadersTransformer implements Transformer {
|
|
|
14
15
|
* path unchanged.
|
|
15
16
|
*/
|
|
16
17
|
private sendWithSessionRetry;
|
|
18
|
+
private preserveZenStreamErrors;
|
|
19
|
+
private static zenStreamFailure;
|
|
17
20
|
private buildHeaders;
|
|
18
21
|
/**
|
|
19
22
|
* True only for the two Zen session-hash routing failures — a re-roll can
|
|
@@ -22,6 +25,9 @@ export declare class OpencodeHeadersTransformer implements Transformer {
|
|
|
22
25
|
* mistaken for routing failures and pass straight through.
|
|
23
26
|
*/
|
|
24
27
|
private isZenRoutingFailure;
|
|
28
|
+
private isZenTransientStatus;
|
|
29
|
+
private retryDelayMs;
|
|
30
|
+
private exponentialRetryDelayMs;
|
|
25
31
|
private retryAfterHeaders;
|
|
26
32
|
private fingerprintConversation;
|
|
27
33
|
private getOrCreateSessionId;
|
|
@@ -19,7 +19,9 @@ export declare function loadTokens(): ClaudeTokens | null;
|
|
|
19
19
|
export declare function saveTokens(tokens: ClaudeTokens): void;
|
|
20
20
|
export declare function isTokenExpired(tokens: ClaudeTokens, leewaySeconds?: number): boolean;
|
|
21
21
|
export declare function refreshTokens(refreshToken: string): Promise<ClaudeTokens>;
|
|
22
|
-
export declare function getValidAccessToken(
|
|
22
|
+
export declare function getValidAccessToken(options?: {
|
|
23
|
+
force?: boolean;
|
|
24
|
+
}): Promise<ClaudeTokens>;
|
|
23
25
|
/**
|
|
24
26
|
* Load the persisted synthesized-client device id, minting and persisting a
|
|
25
27
|
* fresh 64-hex value on first use. Stored alongside the OAuth token file
|
|
@@ -3,11 +3,14 @@ interface QwenTokens {
|
|
|
3
3
|
expiresAt: number | null;
|
|
4
4
|
updatedAt: number;
|
|
5
5
|
}
|
|
6
|
+
declare function getQwenAuthFilePath(): string;
|
|
6
7
|
/**
|
|
7
8
|
* Load a valid (non-expired) Qwen access token, transparently refreshing it
|
|
8
9
|
* via the upstream rotation endpoint when the token is within 6 hours of
|
|
9
10
|
* expiry. Throws with an actionable message if no token is configured or if
|
|
10
11
|
* the refresh attempt fails.
|
|
11
12
|
*/
|
|
12
|
-
export declare function getValidAccessToken(
|
|
13
|
-
|
|
13
|
+
export declare function getValidAccessToken(options?: {
|
|
14
|
+
force?: boolean;
|
|
15
|
+
}): Promise<QwenTokens>;
|
|
16
|
+
export { getQwenAuthFilePath };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode Zen (DeepSeek flash, etc.) glues extra SSE `data:` fields onto the
|
|
3
|
+
* Chat Completions terminator without a blank event separator:
|
|
4
|
+
*
|
|
5
|
+
* data: [DONE]
|
|
6
|
+
* data: {"choices":[],"cost":"0"}
|
|
7
|
+
*
|
|
8
|
+
* data: [DONE] {"choices":[],"cost":"0"}
|
|
9
|
+
*
|
|
10
|
+
* data: {"choices":[],"usage":{...}}
|
|
11
|
+
* data: [DONE]
|
|
12
|
+
*
|
|
13
|
+
* EventSource / AI SDK concatenate those fields with `\n` and JSON.parse the
|
|
14
|
+
* result (`[DONE]\n{…}` or `{…}\n[DONE]`). Close `[DONE]` as its own event and
|
|
15
|
+
* drop anything after it — Chat Completions streams end there.
|
|
16
|
+
*/
|
|
17
|
+
export declare function splitChatCompletionsDoneLine(line: string): string[];
|
|
18
|
+
export declare function isChatCompletionsDoneLine(line: string): boolean;
|
|
19
|
+
/** Always close the previous SSE event before emitting the terminator. */
|
|
20
|
+
export declare function pushChatCompletionsDone(out: string[]): void;
|
|
21
|
+
/**
|
|
22
|
+
* Rewrite a Chat Completions SSE body so `[DONE]` always closes its event and
|
|
23
|
+
* nothing follows it. Idempotent on an already-clean stream.
|
|
24
|
+
*/
|
|
25
|
+
export declare function withChatCompletionsDoneBoundary(body: ReadableStream<Uint8Array>): ReadableStream<Uint8Array>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { SSEParserTransform } from './SSEParser.transform';
|
|
2
2
|
export { SSESerializerTransform } from './SSESerializer.transform';
|
|
3
3
|
export { rewriteStream } from './rewriteStream';
|
|
4
|
+
export { splitChatCompletionsDoneLine, isChatCompletionsDoneLine, pushChatCompletionsDone, withChatCompletionsDoneBoundary, } from './done-boundary';
|
|
4
5
|
export { withSSEClientKeepalive, type SSEClientKeepaliveOptions, } from './client-keepalive';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caeliq/llms",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.63",
|
|
4
4
|
"description": "A universal LLM API transformation server",
|
|
5
5
|
"main": "dist/cjs/server.cjs",
|
|
6
6
|
"module": "dist/esm/server.mjs",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@anthropic-ai/sdk": "^0.115.0",
|
|
33
|
-
"@caeliq/ccr-shared": "^2.1.
|
|
33
|
+
"@caeliq/ccr-shared": "^2.1.5",
|
|
34
34
|
"@cursor/sdk": "^1.0.28",
|
|
35
35
|
"@fastify/cors": "^11.3.0",
|
|
36
36
|
"@fastify/rate-limit": "^11.2.0",
|