@caeliq/llms 1.0.55 → 1.0.57
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 +102 -12
- package/dist/api/middleware.d.ts +9 -0
- package/dist/api/routes.d.ts +15 -0
- package/dist/cjs/server.cjs +238 -230
- package/dist/cjs/server.cjs.map +4 -4
- package/dist/cursor-sdk/events-to-sse.d.ts +113 -0
- package/dist/cursor-sdk/hooks-template.d.ts +1 -0
- package/dist/cursor-sdk/prompt.d.ts +29 -0
- package/dist/cursor-sdk/runner.d.ts +11 -0
- package/dist/cursor-sdk/send.d.ts +9 -0
- package/dist/cursor-sdk/session.d.ts +146 -0
- package/dist/cursor-sdk/shared.d.ts +14 -0
- package/dist/cursor-sdk/tools.d.ts +4 -0
- package/dist/cursor-sdk/usage.d.ts +28 -0
- package/dist/esm/server.mjs +233 -225
- package/dist/esm/server.mjs.map +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/output/console-handler.d.ts +23 -0
- package/dist/plugins/output/index.d.ts +29 -0
- package/dist/plugins/output/output-manager.d.ts +110 -0
- package/dist/plugins/output/temp-file-handler.d.ts +53 -0
- package/dist/plugins/output/types.d.ts +157 -0
- package/dist/plugins/output/webhook-handler.d.ts +37 -0
- package/dist/plugins/plugin-manager.d.ts +62 -0
- package/dist/plugins/token-speed.d.ts +22 -0
- package/dist/plugins/types.d.ts +25 -0
- package/dist/server.d.ts +60 -0
- package/dist/services/config.d.ts +32 -0
- package/dist/services/provider.d.ts +34 -0
- package/dist/services/tokenizer.d.ts +44 -0
- package/dist/services/transformer.d.ts +28 -0
- package/dist/tests/anthropic.stream-boundaries.d.ts +1 -0
- package/dist/tests/anthropic.stream-cancel.d.ts +1 -0
- package/dist/tests/antigravity.claude-tool-schema.d.ts +1 -0
- package/dist/tests/antigravity.endpoint-fallback.d.ts +1 -0
- package/dist/tests/cache-control.strip.d.ts +1 -0
- package/dist/tests/cache-paths.integration.d.ts +1 -0
- package/dist/tests/claude-auth.beta-headers.d.ts +1 -0
- package/dist/tests/codex-auth.reliability.d.ts +1 -0
- package/dist/tests/cursor-sdk.cancel.d.ts +1 -0
- package/dist/tests/cursor-sdk.on-delta-thinking.d.ts +1 -0
- package/dist/tests/cursor-sdk.progress-only.d.ts +1 -0
- package/dist/tests/cursor-sdk.runner-recovery.d.ts +1 -0
- package/dist/tests/cursor-sdk.send.d.ts +1 -0
- package/dist/tests/cursor-sdk.stream-error.d.ts +1 -0
- package/dist/tests/cursor-sdk.thinking-signature.d.ts +1 -0
- package/dist/tests/cursor-sdk.usage.d.ts +1 -0
- package/dist/tests/deepseek.reasoning.d.ts +1 -0
- package/dist/tests/gemini.abnormal-finish.d.ts +1 -0
- package/dist/tests/gemini.dual-dialect-request.d.ts +1 -0
- package/dist/tests/gemini.function-call-signatures.d.ts +1 -0
- package/dist/tests/gemini.parity.d.ts +1 -0
- package/dist/tests/gemini.thinking-effort.d.ts +1 -0
- package/dist/tests/gemini.thought-signature-roundtrip.d.ts +1 -0
- package/dist/tests/opencode-headers.no-provider-retry.d.ts +1 -0
- package/dist/tests/thinking-sequencer.dual-dialect.d.ts +1 -0
- package/dist/tests/transformer-service.endpoints.d.ts +1 -0
- package/dist/tests/upstream-ports.smoke.d.ts +1 -0
- package/dist/tokenizer/api-tokenizer.d.ts +45 -0
- package/dist/tokenizer/huggingface-tokenizer.d.ts +52 -0
- package/dist/tokenizer/tiktoken-tokenizer.d.ts +20 -0
- package/dist/transformer/anthropic.transformer.d.ts +22 -0
- package/dist/transformer/antigravity-auth.transformer.d.ts +15 -0
- package/dist/transformer/cerebras.transformer.d.ts +16 -0
- package/dist/transformer/chrome-on-device.transformer.d.ts +7 -0
- package/dist/transformer/claude-auth.transformer.d.ts +25 -0
- package/dist/transformer/cleancache.transformer.d.ts +6 -0
- package/dist/transformer/codex.transformer.d.ts +61 -0
- package/dist/transformer/cursor-sdk.transformer.d.ts +23 -0
- package/dist/transformer/customparams.transformer.d.ts +30 -0
- package/dist/transformer/deepseek.transformer.d.ts +7 -0
- package/dist/transformer/enhancetool.transformer.d.ts +6 -0
- package/dist/transformer/extrathinktag.transformer.d.ts +10 -0
- package/dist/transformer/forcereasoning.transformer.d.ts +8 -0
- package/dist/transformer/gemini.transformer.d.ts +15 -0
- package/dist/transformer/groq.transformer.d.ts +7 -0
- package/dist/transformer/index.d.ts +65 -0
- package/dist/transformer/maxcompletiontokens.transformer.d.ts +6 -0
- package/dist/transformer/maxtoken.transformer.d.ts +9 -0
- package/dist/transformer/mistral.transformer.d.ts +25 -0
- package/dist/transformer/openai.responses.transformer.d.ts +13 -0
- package/dist/transformer/openai.transformer.d.ts +52 -0
- package/dist/transformer/opencode-headers.transformer.d.ts +30 -0
- package/dist/transformer/openrouter.transformer.d.ts +10 -0
- package/dist/transformer/qwen-auth.transformer.d.ts +9 -0
- package/dist/transformer/reasoning.transformer.d.ts +10 -0
- package/dist/transformer/sampling.transformer.d.ts +13 -0
- package/dist/transformer/streamoptions.transformer.d.ts +6 -0
- package/dist/transformer/tooluse.transformer.d.ts +7 -0
- package/dist/transformer/vercel.transformer.d.ts +11 -0
- package/dist/transformer/vertex-claude.transformer.d.ts +9 -0
- package/dist/transformer/vertex-gemini.transformer.d.ts +12 -0
- package/dist/transformer/vertex-openai.transformer.d.ts +19 -0
- package/dist/types/llm.d.ts +255 -0
- package/dist/types/transformer.d.ts +23 -0
- package/dist/utils/antigravity-auth.d.ts +75 -0
- package/dist/utils/auth-recovery.d.ts +2 -0
- package/dist/utils/cache.d.ts +14 -0
- package/dist/utils/cacheControl.d.ts +44 -0
- package/dist/utils/claude-auth.d.ts +22 -0
- package/dist/utils/codex-auth.d.ts +33 -0
- package/dist/utils/converter.d.ts +11 -0
- package/dist/utils/cursor-auth.d.ts +3 -0
- package/dist/utils/deepseek.util.d.ts +28 -0
- package/dist/utils/gemini-cache.d.ts +8 -0
- package/dist/utils/gemini-thinking.d.ts +66 -0
- package/dist/utils/gemini.util.d.ts +43 -0
- package/dist/utils/google.util.d.ts +160 -0
- package/dist/utils/image.d.ts +1 -0
- package/dist/utils/mistral.util.d.ts +14 -0
- package/dist/utils/openai.util.d.ts +17 -0
- package/dist/utils/qwen-auth.d.ts +13 -0
- package/dist/utils/redact.d.ts +30 -0
- package/dist/utils/request.d.ts +4 -0
- package/dist/utils/retry.d.ts +27 -0
- package/dist/utils/router.d.ts +42 -0
- package/dist/utils/schema.d.ts +46 -0
- package/dist/utils/sse/SSEParser.transform.d.ts +6 -0
- package/dist/utils/sse/SSESerializer.transform.d.ts +3 -0
- package/dist/utils/sse/index.d.ts +3 -0
- package/dist/utils/sse/rewriteStream.d.ts +9 -0
- package/dist/utils/stream.d.ts +11 -0
- package/dist/utils/thinking.d.ts +33 -0
- package/dist/utils/thought-signature-cache.d.ts +34 -0
- package/dist/utils/toolArgumentsParser.d.ts +8 -0
- package/dist/utils/vertex-claude.util.d.ts +47 -0
- package/package.json +3 -3
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rewrite stream utility
|
|
3
|
+
* Reads source readablestream and returns a new readablestream,
|
|
4
|
+
* processor processes source data and pushes returned new value to new stream,
|
|
5
|
+
* no push if no return value
|
|
6
|
+
* @param stream
|
|
7
|
+
* @param processor
|
|
8
|
+
*/
|
|
9
|
+
export declare const rewriteStream: (stream: ReadableStream, processor: (data: any, controller: ReadableStreamController<any>) => Promise<any>) => ReadableStream;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface StreamContext {
|
|
2
|
+
controller: ReadableStreamDefaultController;
|
|
3
|
+
encoder: TextEncoder;
|
|
4
|
+
}
|
|
5
|
+
export declare function createSSEStreamReader(response: Response, processLine: (line: string, context: StreamContext) => void, options?: {
|
|
6
|
+
bufferSize?: number;
|
|
7
|
+
onComplete?: (context: StreamContext) => void;
|
|
8
|
+
logger?: any;
|
|
9
|
+
}): Response;
|
|
10
|
+
export declare function encodeSSEData(data: string, encoder: TextEncoder): Uint8Array;
|
|
11
|
+
export declare function encodeSSELine(line: string, encoder: TextEncoder): Uint8Array;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accumulator for streaming reasoning/thinking content.
|
|
3
|
+
* Used to buffer reasoning chunks across SSE events and emit
|
|
4
|
+
* a final thinking block with signature when reasoning completes.
|
|
5
|
+
*/
|
|
6
|
+
export interface ReasoningAccumulator {
|
|
7
|
+
content: string;
|
|
8
|
+
isComplete: boolean;
|
|
9
|
+
hasContent: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function createReasoningAccumulator(): ReasoningAccumulator;
|
|
12
|
+
export declare function accumulateReasoning(accumulator: ReasoningAccumulator, text: string): void;
|
|
13
|
+
export declare function finalizeReasoning(accumulator: ReasoningAccumulator): {
|
|
14
|
+
content: string;
|
|
15
|
+
signature: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Build a chat.completion.chunk with a thinking delta.
|
|
19
|
+
* Used when emitting accumulated reasoning content as a thinking block.
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildThinkingChunk(baseData: any, thinking: {
|
|
22
|
+
content?: string;
|
|
23
|
+
signature?: string;
|
|
24
|
+
}): any;
|
|
25
|
+
/**
|
|
26
|
+
* Extract reasoning text from various provider-specific delta fields.
|
|
27
|
+
* Supports: delta.reasoning_content (DeepSeek/Mistral), delta.reasoning (OpenRouter)
|
|
28
|
+
*/
|
|
29
|
+
export declare function extractReasoningText(delta: any): string | null;
|
|
30
|
+
/**
|
|
31
|
+
* Remove reasoning-specific fields from a delta after extraction.
|
|
32
|
+
*/
|
|
33
|
+
export declare function cleanReasoningFields(delta: any): void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thought signatures for tool calls, carried across turns on behalf of clients
|
|
3
|
+
* that cannot round-trip them.
|
|
4
|
+
*
|
|
5
|
+
* Gemini 3 / Antigravity sign the reasoning behind every `functionCall` and
|
|
6
|
+
* expect that signature back when the call is replayed. Anthropic's `tool_use`
|
|
7
|
+
* block has no field to carry it — and must not grow one, since Claude Code's
|
|
8
|
+
* wire format is fixed — so the signature is lost the moment a turn reaches the
|
|
9
|
+
* client. The documented `skip_thought_signature_validator` sentinel stops the
|
|
10
|
+
* request from 400ing, but Google is explicit that it is a last resort that
|
|
11
|
+
* "will negatively impact model performance": the model is handed back its own
|
|
12
|
+
* earlier tool calls stripped of the signed reasoning that produced them.
|
|
13
|
+
*
|
|
14
|
+
* Observed consequence in a long Claude Code session: upstream signatures shrank
|
|
15
|
+
* from ~1.2 KB to a 56-byte stub over six replayed tool calls, then the model
|
|
16
|
+
* emitted an empty `functionCall` and the turn died with
|
|
17
|
+
* `MALFORMED_FUNCTION_CALL` ("Function call is empty - no input to parse").
|
|
18
|
+
*
|
|
19
|
+
* So CCR keeps the signatures here instead of discarding them, keyed by the one
|
|
20
|
+
* identifier that does survive the round trip:
|
|
21
|
+
*
|
|
22
|
+
* upstream functionCall.id → Anthropic tool_use.id
|
|
23
|
+
* → tool_result.tool_use_id → Unified tool_calls[].id
|
|
24
|
+
*
|
|
25
|
+
* Entries are scoped per provider: a signature minted by one upstream is not
|
|
26
|
+
* valid at another, so a conversation re-routed mid-session misses the cache and
|
|
27
|
+
* falls back to the sentinel rather than replaying a foreign signature.
|
|
28
|
+
*/
|
|
29
|
+
export declare function rememberThoughtSignature(scope: string | undefined, id: string | undefined, signature: string | undefined): void;
|
|
30
|
+
export declare function recallThoughtSignature(scope: string | undefined, id: string | undefined): string | undefined;
|
|
31
|
+
/** Test hook. */
|
|
32
|
+
export declare function clearThoughtSignatureCache(): void;
|
|
33
|
+
/** Test hook. */
|
|
34
|
+
export declare function thoughtSignatureCacheSize(): number;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse tool call arguments function
|
|
3
|
+
* First try standard JSON parsing, then JSON5 parsing, finally use jsonrepair for safe repair
|
|
4
|
+
*
|
|
5
|
+
* @param argsString - Parameter string to parse
|
|
6
|
+
* @returns Parsed parameter object or safe empty object
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseToolArguments(argsString: string, logger?: any): string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { UnifiedChatRequest } from "../types/llm";
|
|
2
|
+
interface ClaudeMessage {
|
|
3
|
+
role: "user" | "assistant";
|
|
4
|
+
content: Array<{
|
|
5
|
+
type: "text" | "image" | "tool_use" | "tool_result";
|
|
6
|
+
text?: string;
|
|
7
|
+
source?: {
|
|
8
|
+
type: "base64";
|
|
9
|
+
media_type: string;
|
|
10
|
+
data: string;
|
|
11
|
+
};
|
|
12
|
+
id?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
input?: Record<string, any>;
|
|
15
|
+
tool_use_id?: string;
|
|
16
|
+
content?: string | Array<any>;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
interface ClaudeTool {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
input_schema: {
|
|
23
|
+
type: string;
|
|
24
|
+
properties: Record<string, any>;
|
|
25
|
+
required?: string[];
|
|
26
|
+
additionalProperties?: boolean;
|
|
27
|
+
$schema?: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
interface VertexClaudeRequest {
|
|
31
|
+
anthropic_version: "vertex-2023-10-16";
|
|
32
|
+
messages: ClaudeMessage[];
|
|
33
|
+
max_tokens: number;
|
|
34
|
+
stream?: boolean;
|
|
35
|
+
temperature?: number;
|
|
36
|
+
top_p?: number;
|
|
37
|
+
top_k?: number;
|
|
38
|
+
tools?: ClaudeTool[];
|
|
39
|
+
tool_choice?: "auto" | "none" | {
|
|
40
|
+
type: "tool";
|
|
41
|
+
name: string;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export declare function buildRequestBody(request: UnifiedChatRequest): VertexClaudeRequest;
|
|
45
|
+
export declare function transformRequestOut(request: Record<string, any>): UnifiedChatRequest;
|
|
46
|
+
export declare function transformResponseOut(response: Response, providerName: string, logger?: any): Promise<Response>;
|
|
47
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caeliq/llms",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.57",
|
|
4
4
|
"description": "A universal LLM API transformation server",
|
|
5
5
|
"main": "dist/cjs/server.cjs",
|
|
6
6
|
"module": "dist/esm/server.mjs",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@anthropic-ai/sdk": "^0.54.0",
|
|
33
|
-
"@caeliq/ccr-shared": "^2.0.
|
|
33
|
+
"@caeliq/ccr-shared": "^2.0.3",
|
|
34
34
|
"@cursor/sdk": "^1.0.23",
|
|
35
35
|
"@fastify/cors": "^11.0.1",
|
|
36
|
-
"@google/genai": "^
|
|
36
|
+
"@google/genai": "^2.13.0",
|
|
37
37
|
"@huggingface/tokenizers": "^0.0.6",
|
|
38
38
|
"dotenv": "^16.5.0",
|
|
39
39
|
"fastify": "^5.4.0",
|