@wengine-ai/llms 2.3.2403 → 2.3.2405
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 +2 -2
- package/dist/cjs/server.cjs +161 -161
- package/dist/cjs/server.cjs.map +4 -4
- package/dist/esm/server.mjs +156 -156
- package/dist/esm/server.mjs.map +4 -4
- package/dist/index.html +20 -20
- package/dist/transformer/defaultthinking.transformer.d.ts +39 -0
- package/dist/transformer/index.d.ts +2 -0
- package/dist/transformer/opencode.transformer.d.ts +16 -1
- package/dist/utils/thinking.d.ts +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { UnifiedChatRequest } from "../types/llm";
|
|
2
|
+
import { Transformer, TransformerOptions } from "../types/transformer";
|
|
3
|
+
export type DefaultThinkingLevel = "none" | "low" | "medium" | "high";
|
|
4
|
+
type EndpointKind = "anthropic" | "responses" | "chat";
|
|
5
|
+
/**
|
|
6
|
+
* Resolve the provider's upstream endpoint kind from its base URL so the
|
|
7
|
+
* default thinking level can be expressed in the endpoint's native parameter.
|
|
8
|
+
* Defaults to OpenAI-compatible chat completions, the most common shape.
|
|
9
|
+
*/
|
|
10
|
+
export declare function sniffEndpointKind(baseUrl?: string): EndpointKind;
|
|
11
|
+
/**
|
|
12
|
+
* DefaultThinkingTransformer
|
|
13
|
+
*
|
|
14
|
+
* Applies a provider-configured default thinking level when the client did
|
|
15
|
+
* not express any thinking intent. Configured via the provider field
|
|
16
|
+
* `default_thinking_level` (wired into the chain by ProviderService) or
|
|
17
|
+
* directly as `["defaultthinking", { "level": "high" }]` in a transformer
|
|
18
|
+
* `use` list.
|
|
19
|
+
*
|
|
20
|
+
* The level is converted to whatever parameter the provider's endpoint
|
|
21
|
+
* speaks:
|
|
22
|
+
* - Anthropic /v1/messages: unified `reasoning` (converted to the Anthropic
|
|
23
|
+
* `thinking` block by convertToAnthropic)
|
|
24
|
+
* - OpenAI /v1/responses: unified `reasoning` (mapped to `reasoning.effort`
|
|
25
|
+
* by OpenAIResponsesTransformer)
|
|
26
|
+
* - OpenAI-compatible /v1/chat/completions: `reasoning_effort`
|
|
27
|
+
*
|
|
28
|
+
* Client intent always wins: any defined `request.reasoning` — including an
|
|
29
|
+
* explicit disabled — skips injection entirely. `level: "none"` (or an
|
|
30
|
+
* unknown value) is a no-op, so the field can stay set in config while
|
|
31
|
+
* effectively off.
|
|
32
|
+
*/
|
|
33
|
+
export declare class DefaultThinkingTransformer implements Transformer {
|
|
34
|
+
private readonly options?;
|
|
35
|
+
static TransformerName: string;
|
|
36
|
+
constructor(options?: TransformerOptions | undefined);
|
|
37
|
+
transformRequestIn(request: UnifiedChatRequest, provider?: any): Promise<Record<string, any>>;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -21,6 +21,7 @@ import { OpenAIResponsesTransformer } from "./openai.responses.transformer";
|
|
|
21
21
|
import { ForceReasoningTransformer } from "./forcereasoning.transformer";
|
|
22
22
|
import { KimiTransformer } from "./kimi.transformer";
|
|
23
23
|
import { OpenCodeTransformer } from "./opencode.transformer";
|
|
24
|
+
import { DefaultThinkingTransformer } from "./defaultthinking.transformer";
|
|
24
25
|
declare const _default: {
|
|
25
26
|
AnthropicTransformer: typeof AnthropicTransformer;
|
|
26
27
|
GeminiTransformer: typeof GeminiTransformer;
|
|
@@ -45,5 +46,6 @@ declare const _default: {
|
|
|
45
46
|
ForceReasoningTransformer: typeof ForceReasoningTransformer;
|
|
46
47
|
KimiTransformer: typeof KimiTransformer;
|
|
47
48
|
OpenCodeTransformer: typeof OpenCodeTransformer;
|
|
49
|
+
DefaultThinkingTransformer: typeof DefaultThinkingTransformer;
|
|
48
50
|
};
|
|
49
51
|
export default _default;
|
|
@@ -25,12 +25,27 @@ import { Transformer, TransformerOptions } from "../types/transformer";
|
|
|
25
25
|
* thinking format expected by Claude Code.
|
|
26
26
|
* - Replaces purely-numeric tool_call IDs with UUID-based IDs to avoid
|
|
27
27
|
* downstream parsing issues.
|
|
28
|
+
* - Sends a stable x-opencode-session header. OpenCode Go rejects requests
|
|
29
|
+
* without it (400 MissingSessionID) and uses the value for routing and
|
|
30
|
+
* prompt caching, so it must stay constant for the whole conversation —
|
|
31
|
+
* reusing the coding agent's own session id is the intended usage.
|
|
28
32
|
*/
|
|
29
33
|
export declare class OpenCodeTransformer implements Transformer {
|
|
30
34
|
private readonly options?;
|
|
31
35
|
static TransformerName: string;
|
|
32
36
|
endPoint: string;
|
|
33
37
|
constructor(options?: TransformerOptions | undefined);
|
|
34
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Resolve a stable per-conversation session id for x-opencode-session.
|
|
40
|
+
*
|
|
41
|
+
* Priority: the client's own x-opencode-session header (opencode CLI native),
|
|
42
|
+
* the session id CCR's client adapter already extracted (Claude Code encodes
|
|
43
|
+
* it in metadata.user_id), the same value mirrored onto req.sessionId, a
|
|
44
|
+
* direct extraction from the body's metadata.user_id, and finally the Codex
|
|
45
|
+
* native session_id header. A per-request UUID is the last resort: it keeps
|
|
46
|
+
* Go endpoints from 400ing but forfeits their cross-request cache affinity.
|
|
47
|
+
*/
|
|
48
|
+
private resolveSessionId;
|
|
49
|
+
transformRequestIn(request: UnifiedChatRequest, provider?: any, context?: Record<string, any>): Promise<Record<string, any>>;
|
|
35
50
|
transformResponseOut(response: Response): Promise<Response>;
|
|
36
51
|
}
|
package/dist/utils/thinking.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wengine-ai/llms",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2405",
|
|
4
4
|
"description": "A universal LLM API transformation server",
|
|
5
5
|
"main": "dist/cjs/server.cjs",
|
|
6
6
|
"module": "dist/esm/server.mjs",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"uuid": "^11.1.0",
|
|
53
53
|
"@fastify/multipart": "^9.0.0",
|
|
54
54
|
"@fastify/static": "^8.2.0",
|
|
55
|
-
"@wengine-ai/claude-code-router-shared": "^2.3.
|
|
55
|
+
"@wengine-ai/claude-code-router-shared": "^2.3.2405",
|
|
56
56
|
"adm-zip": "^0.5.16",
|
|
57
57
|
"better-sqlite3": "^12.10.0",
|
|
58
58
|
"rotating-file-stream": "^3.2.7"
|