@wengine-ai/llms 2.3.2404 → 2.3.2406

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.
@@ -0,0 +1,65 @@
1
+ import { UnifiedChatRequest, ThinkLevel } from "../types/llm";
2
+ import { Transformer, TransformerOptions } from "../types/transformer";
3
+ export type DefaultThinkingLevel = "none" | "low" | "medium" | "high" | "max";
4
+ type EndpointKind = "anthropic" | "responses" | "chat";
5
+ /**
6
+ * Extra spellings of the standard levels, kept so configs written before the
7
+ * ladder grew a "max" tier (and provider docs that name their tiers
8
+ * differently) still resolve: GLM publishes minimal|light|low → low and
9
+ * xhigh|max|ultra → max.
10
+ */
11
+ export declare const ALIAS_LEVELS: Record<string, ThinkLevel>;
12
+ /**
13
+ * Parse the configured level. Accepted forms:
14
+ * - "none" | "low" | "medium" | "high" | "max" — the standard enum
15
+ * - a positive integer (or its decimal string form) — custom token budget
16
+ * - any other non-empty string — provider-specific level passed through
17
+ * verbatim (e.g. "off"); only meaningful on OpenAI-style endpoints, which
18
+ * accept free-form effort values
19
+ * Empty/unparsable input parses as undefined (no injection).
20
+ */
21
+ export declare function parseThinkingLevel(raw: unknown): DefaultThinkingLevel | number | string | undefined;
22
+ /**
23
+ * Resolve the provider's upstream endpoint kind from its base URL so the
24
+ * default thinking level can be expressed in the endpoint's native parameter.
25
+ * Defaults to OpenAI-compatible chat completions, the most common shape.
26
+ */
27
+ export declare function sniffEndpointKind(baseUrl?: string): EndpointKind;
28
+ /**
29
+ * DefaultThinkingTransformer
30
+ *
31
+ * Applies a provider-configured default thinking level when the client did
32
+ * not express any thinking intent. Configured via the provider field
33
+ * `default_thinking_level` (wired into the chain by ProviderService) or
34
+ * directly as `["defaultthinking", { "level": "high" }]` in a transformer
35
+ * `use` list.
36
+ *
37
+ * The value is one of "low" | "medium" | "high" | "max", a custom token budget
38
+ * (number or numeric string), or a provider-specific effort string passed
39
+ * through verbatim. Conversion per endpoint kind:
40
+ * - Anthropic /v1/messages: unified `reasoning` — levels ride the effort enum
41
+ * (`output_config.effort`, which is what current Anthropic models and
42
+ * Anthropic-compatible providers such as GLM actually read) with a matching
43
+ * thinking budget; a custom budget flows into `reasoning.max_tokens` (kept
44
+ * as the exact budget by convertToAnthropic, raised to Anthropic's 1024
45
+ * minimum); known aliases (min|minimal|light→low, xhigh|maximum|ultra→max)
46
+ * resolve to their level; any other string is skipped (no string form
47
+ * exists).
48
+ * - OpenAI /v1/responses: unified `reasoning` mapped to `reasoning.effort` —
49
+ * custom budgets collapse to the closest effort enum, free-form strings
50
+ * pass through.
51
+ * - OpenAI-compatible /v1/chat/completions: `reasoning_effort` — same enum
52
+ * mapping for budgets, verbatim passthrough for free-form strings.
53
+ *
54
+ * Client intent always wins: any defined `request.reasoning` — including an
55
+ * explicit disabled — skips injection entirely. "none" (or an unparsable
56
+ * value) is a no-op, so the field can stay set in config while effectively
57
+ * off.
58
+ */
59
+ export declare class DefaultThinkingTransformer implements Transformer {
60
+ private readonly options?;
61
+ static TransformerName: string;
62
+ constructor(options?: TransformerOptions | undefined);
63
+ transformRequestIn(request: UnifiedChatRequest, provider?: any): Promise<Record<string, any>>;
64
+ }
65
+ 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;
@@ -66,7 +66,7 @@ export interface UnifiedTool {
66
66
  };
67
67
  };
68
68
  }
69
- export type ThinkLevel = "none" | "low" | "medium" | "high";
69
+ export type ThinkLevel = "none" | "low" | "medium" | "high" | "max";
70
70
  export interface UnifiedChatRequest {
71
71
  messages: UnifiedMessage[];
72
72
  model: string;
@@ -1,2 +1,25 @@
1
1
  import { ThinkLevel } from "../types/llm";
2
2
  export declare const getThinkLevel: (thinking_budget: number) => ThinkLevel;
3
+ export declare const getThinkBudget: (level: ThinkLevel) => number;
4
+ /**
5
+ * Effort values safe to send as an explicit Anthropic `output_config.effort`.
6
+ *
7
+ * "max" is deliberately absent: upstream it is model-gated (only the newest
8
+ * Opus exposes it), while the providers that do accept it — GLM and other
9
+ * Anthropic-compatible endpoints — already resolve a bare enabled thinking
10
+ * block to their own max tier. Sending it would risk a 400 without buying
11
+ * anything, so max rides on the thinking budget instead.
12
+ */
13
+ export declare const ANTHROPIC_EFFORT_LEVELS: ThinkLevel[];
14
+ /**
15
+ * Alias table for effort values seen in the wild, normalized onto the unified
16
+ * ladder. Mirrors what Anthropic-compatible providers publish (GLM documents
17
+ * minimal|light|low → low, medium|high → high, xhigh|max|ultra → max).
18
+ */
19
+ export declare const EFFORT_ALIASES: Record<string, ThinkLevel>;
20
+ /**
21
+ * Normalize a client- or config-supplied effort value onto the unified ladder.
22
+ * Unknown strings return undefined so callers can keep them verbatim on
23
+ * endpoints that accept free-form values (OpenAI-style `reasoning_effort`).
24
+ */
25
+ export declare const normalizeEffort: (raw: unknown) => ThinkLevel | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wengine-ai/llms",
3
- "version": "2.3.2404",
3
+ "version": "2.3.2406",
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.2404",
55
+ "@wengine-ai/claude-code-router-shared": "^2.3.2406",
56
56
  "adm-zip": "^0.5.16",
57
57
  "better-sqlite3": "^12.10.0",
58
58
  "rotating-file-stream": "^3.2.7"