@gajae-code/ai 0.17.1 → 0.17.4

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +117 -0
  2. package/dist/types/auth-gateway/server.d.ts +23 -1
  3. package/dist/types/auth-storage.d.ts +12 -1
  4. package/dist/types/model-thinking.d.ts +10 -6
  5. package/dist/types/provider-models/openai-compat.d.ts +2 -2
  6. package/dist/types/providers/anthropic.d.ts +1 -1
  7. package/dist/types/providers/cursor.d.ts +10 -0
  8. package/dist/types/providers/openai-completions.d.ts +9 -1
  9. package/dist/types/types.d.ts +16 -0
  10. package/dist/types/utils/discovery/openai-compatible.d.ts +10 -0
  11. package/dist/types/utils/fallback-transport.d.ts +4 -0
  12. package/dist/types/utils/h2-fetch.d.ts +8 -2
  13. package/dist/types/utils/stream-repetition-guard.d.ts +107 -0
  14. package/dist/types/utils/tool-call-healing.d.ts +4 -0
  15. package/dist/types/utils/tool-fence-strip.d.ts +27 -0
  16. package/package.json +3 -3
  17. package/src/auth-gateway/server.ts +48 -9
  18. package/src/auth-storage.ts +185 -48
  19. package/src/model-manager.ts +11 -8
  20. package/src/model-pricing.ts +22 -0
  21. package/src/model-thinking.d.ts +10 -6
  22. package/src/model-thinking.ts +93 -11
  23. package/src/models.json +241 -15
  24. package/src/provider-models/openai-compat.ts +27 -19
  25. package/src/providers/anthropic.d.ts +1 -1
  26. package/src/providers/anthropic.ts +10 -2
  27. package/src/providers/cursor.d.ts +10 -0
  28. package/src/providers/cursor.ts +176 -31
  29. package/src/providers/openai-completions.d.ts +9 -1
  30. package/src/providers/openai-completions.ts +379 -128
  31. package/src/providers/openai-opencodex-responses.ts +15 -5
  32. package/src/stream.ts +24 -1
  33. package/src/types.d.ts +16 -0
  34. package/src/types.ts +17 -0
  35. package/src/utils/discovery/openai-compatible.ts +16 -2
  36. package/src/utils/fallback-transport.d.ts +4 -0
  37. package/src/utils/fallback-transport.ts +11 -0
  38. package/src/utils/h2-fetch.ts +70 -7
  39. package/src/utils/http-inspector.ts +4 -2
  40. package/src/utils/idle-iterator.ts +109 -96
  41. package/src/utils/json-parse.ts +12 -4
  42. package/src/utils/stream-repetition-guard.d.ts +107 -0
  43. package/src/utils/stream-repetition-guard.ts +290 -0
  44. package/src/utils/tool-call-healing.d.ts +4 -0
  45. package/src/utils/tool-call-healing.ts +4 -0
  46. package/src/utils/tool-fence-strip.d.ts +27 -0
  47. package/src/utils/tool-fence-strip.ts +64 -0
package/src/models.json CHANGED
@@ -116,6 +116,76 @@
116
116
  "maxLevel": "xhigh"
117
117
  }
118
118
  },
119
+ "deepseek-v4-pro-0813": {
120
+ "id": "deepseek-v4-pro-0813",
121
+ "name": "DeepSeek V4 Pro 0813",
122
+ "api": "openai-completions",
123
+ "provider": "alibaba-token-plan",
124
+ "baseUrl": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
125
+ "reasoning": true,
126
+ "input": [
127
+ "text"
128
+ ],
129
+ "cost": {
130
+ "input": 0,
131
+ "output": 0,
132
+ "cacheRead": 0,
133
+ "cacheWrite": 0
134
+ },
135
+ "contextWindow": 1000000,
136
+ "maxTokens": 384000,
137
+ "compat": {
138
+ "supportsDeveloperRole": false,
139
+ "supportsReasoningEffort": true,
140
+ "reasoningContentField": "reasoning_content",
141
+ "requiresReasoningContentForToolCalls": true
142
+ },
143
+ "thinking": {
144
+ "mode": "effort",
145
+ "minLevel": "low",
146
+ "maxLevel": "max",
147
+ "levels": [
148
+ "low",
149
+ "high",
150
+ "max"
151
+ ]
152
+ }
153
+ },
154
+ "deepseek-v4.1-flash": {
155
+ "id": "deepseek-v4.1-flash",
156
+ "name": "DeepSeek V4.1 Flash",
157
+ "api": "openai-completions",
158
+ "provider": "alibaba-token-plan",
159
+ "baseUrl": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
160
+ "reasoning": true,
161
+ "input": [
162
+ "text"
163
+ ],
164
+ "cost": {
165
+ "input": 0,
166
+ "output": 0,
167
+ "cacheRead": 0,
168
+ "cacheWrite": 0
169
+ },
170
+ "contextWindow": 1000000,
171
+ "maxTokens": 384000,
172
+ "compat": {
173
+ "supportsDeveloperRole": false,
174
+ "supportsReasoningEffort": true,
175
+ "reasoningContentField": "reasoning_content",
176
+ "requiresReasoningContentForToolCalls": true
177
+ },
178
+ "thinking": {
179
+ "mode": "effort",
180
+ "minLevel": "low",
181
+ "maxLevel": "max",
182
+ "levels": [
183
+ "low",
184
+ "high",
185
+ "max"
186
+ ]
187
+ }
188
+ },
119
189
  "glm-5": {
120
190
  "id": "glm-5",
121
191
  "name": "GLM-5",
@@ -197,6 +267,42 @@
197
267
  "maxLevel": "xhigh"
198
268
  }
199
269
  },
270
+ "glm-5.3": {
271
+ "id": "glm-5.3",
272
+ "name": "GLM-5.3",
273
+ "api": "openai-completions",
274
+ "provider": "alibaba-token-plan",
275
+ "baseUrl": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
276
+ "reasoning": true,
277
+ "input": [
278
+ "text"
279
+ ],
280
+ "cost": {
281
+ "input": 0,
282
+ "output": 0,
283
+ "cacheRead": 0,
284
+ "cacheWrite": 0
285
+ },
286
+ "contextWindow": 1000000,
287
+ "maxTokens": 131072,
288
+ "compat": {
289
+ "supportsDeveloperRole": false,
290
+ "supportsReasoningEffort": true,
291
+ "reasoningContentField": "reasoning_content",
292
+ "requiresReasoningContentForToolCalls": true
293
+ },
294
+ "thinking": {
295
+ "mode": "effort",
296
+ "minLevel": "low",
297
+ "maxLevel": "max",
298
+ "defaultLevel": "max",
299
+ "levels": [
300
+ "low",
301
+ "high",
302
+ "max"
303
+ ]
304
+ }
305
+ },
200
306
  "kimi-k2.5": {
201
307
  "id": "kimi-k2.5",
202
308
  "name": "Kimi K2.5",
@@ -46019,9 +46125,9 @@
46019
46125
  "contextWindow": 1000000,
46020
46126
  "maxTokens": 128000,
46021
46127
  "thinking": {
46022
- "mode": "budget",
46023
- "minLevel": "minimal",
46024
- "maxLevel": "xhigh"
46128
+ "mode": "effort",
46129
+ "minLevel": "high",
46130
+ "maxLevel": "high"
46025
46131
  }
46026
46132
  },
46027
46133
  "MiniMax-M3[1m]": {
@@ -46044,9 +46150,9 @@
46044
46150
  "contextWindow": 1000000,
46045
46151
  "maxTokens": 128000,
46046
46152
  "thinking": {
46047
- "mode": "budget",
46048
- "minLevel": "minimal",
46049
- "maxLevel": "xhigh"
46153
+ "mode": "effort",
46154
+ "minLevel": "high",
46155
+ "maxLevel": "high"
46050
46156
  }
46051
46157
  }
46052
46158
  },
@@ -46239,9 +46345,9 @@
46239
46345
  "contextWindow": 1000000,
46240
46346
  "maxTokens": 128000,
46241
46347
  "thinking": {
46242
- "mode": "budget",
46243
- "minLevel": "minimal",
46244
- "maxLevel": "xhigh"
46348
+ "mode": "effort",
46349
+ "minLevel": "high",
46350
+ "maxLevel": "high"
46245
46351
  }
46246
46352
  },
46247
46353
  "MiniMax-M3[1m]": {
@@ -46264,9 +46370,9 @@
46264
46370
  "contextWindow": 1000000,
46265
46371
  "maxTokens": 128000,
46266
46372
  "thinking": {
46267
- "mode": "budget",
46268
- "minLevel": "minimal",
46269
- "maxLevel": "xhigh"
46373
+ "mode": "effort",
46374
+ "minLevel": "high",
46375
+ "maxLevel": "high"
46270
46376
  }
46271
46377
  }
46272
46378
  },
@@ -46538,7 +46644,7 @@
46538
46644
  },
46539
46645
  "thinking": {
46540
46646
  "mode": "effort",
46541
- "minLevel": "minimal",
46647
+ "minLevel": "high",
46542
46648
  "maxLevel": "high"
46543
46649
  }
46544
46650
  }
@@ -46811,7 +46917,7 @@
46811
46917
  },
46812
46918
  "thinking": {
46813
46919
  "mode": "effort",
46814
- "minLevel": "minimal",
46920
+ "minLevel": "high",
46815
46921
  "maxLevel": "high"
46816
46922
  }
46817
46923
  }
@@ -65544,6 +65650,76 @@
65544
65650
  },
65545
65651
  "applyPatchToolType": "freeform"
65546
65652
  },
65653
+ "gpt-6-luna": {
65654
+ "id": "gpt-6-luna",
65655
+ "name": "GPT-6-Luna",
65656
+ "api": "openai-codex-responses",
65657
+ "provider": "openai-codex",
65658
+ "baseUrl": "https://chatgpt.com/backend-api",
65659
+ "reasoning": true,
65660
+ "input": [
65661
+ "text",
65662
+ "image"
65663
+ ],
65664
+ "cost": {
65665
+ "input": 0.1,
65666
+ "output": 0.5,
65667
+ "cacheRead": 0.01,
65668
+ "cacheWrite": 0.125
65669
+ },
65670
+ "contextWindow": 272000,
65671
+ "maxTokens": 128000,
65672
+ "preferWebsockets": true,
65673
+ "thinking": {
65674
+ "mode": "effort",
65675
+ "minLevel": "low",
65676
+ "maxLevel": "max"
65677
+ },
65678
+ "longContextPricing": {
65679
+ "threshold": 272000,
65680
+ "cost": {
65681
+ "input": 0.2,
65682
+ "output": 0.75,
65683
+ "cacheRead": 0.02,
65684
+ "cacheWrite": 0.25
65685
+ }
65686
+ }
65687
+ },
65688
+ "gpt-6-sol": {
65689
+ "id": "gpt-6-sol",
65690
+ "name": "GPT-6-Sol",
65691
+ "api": "openai-codex-responses",
65692
+ "provider": "openai-codex",
65693
+ "baseUrl": "https://chatgpt.com/backend-api",
65694
+ "reasoning": true,
65695
+ "input": [
65696
+ "text",
65697
+ "image"
65698
+ ],
65699
+ "cost": {
65700
+ "input": 2,
65701
+ "output": 10,
65702
+ "cacheRead": 0.2,
65703
+ "cacheWrite": 2.5
65704
+ },
65705
+ "contextWindow": 272000,
65706
+ "maxTokens": 128000,
65707
+ "preferWebsockets": true,
65708
+ "thinking": {
65709
+ "mode": "effort",
65710
+ "minLevel": "low",
65711
+ "maxLevel": "max"
65712
+ },
65713
+ "longContextPricing": {
65714
+ "threshold": 272000,
65715
+ "cost": {
65716
+ "input": 4,
65717
+ "output": 15,
65718
+ "cacheRead": 0.4,
65719
+ "cacheWrite": 5
65720
+ }
65721
+ }
65722
+ },
65547
65723
  "gpt-daybreak-blue-latest": {
65548
65724
  "id": "gpt-daybreak-blue-latest",
65549
65725
  "name": "Daybreak Blue",
@@ -66611,6 +66787,31 @@
66611
66787
  "minLevel": "minimal",
66612
66788
  "maxLevel": "xhigh"
66613
66789
  }
66790
+ },
66791
+ "union-alpha": {
66792
+ "id": "union-alpha",
66793
+ "name": "Union Alpha Free",
66794
+ "api": "anthropic-messages",
66795
+ "provider": "opencode-go",
66796
+ "baseUrl": "https://opencode.ai/zen/go",
66797
+ "reasoning": true,
66798
+ "input": [
66799
+ "text",
66800
+ "image"
66801
+ ],
66802
+ "cost": {
66803
+ "input": 0,
66804
+ "output": 0,
66805
+ "cacheRead": 0,
66806
+ "cacheWrite": 0
66807
+ },
66808
+ "contextWindow": 262144,
66809
+ "maxTokens": 131072,
66810
+ "thinking": {
66811
+ "mode": "budget",
66812
+ "minLevel": "minimal",
66813
+ "maxLevel": "xhigh"
66814
+ }
66614
66815
  }
66615
66816
  },
66616
66817
  "opencode-zen": {
@@ -68629,6 +68830,31 @@
68629
68830
  },
68630
68831
  "contextWindow": 131072,
68631
68832
  "maxTokens": 131072
68833
+ },
68834
+ "union-alpha": {
68835
+ "id": "union-alpha",
68836
+ "name": "Union Alpha Free",
68837
+ "api": "anthropic-messages",
68838
+ "provider": "opencode-zen",
68839
+ "baseUrl": "https://opencode.ai/zen",
68840
+ "reasoning": true,
68841
+ "input": [
68842
+ "text",
68843
+ "image"
68844
+ ],
68845
+ "cost": {
68846
+ "input": 0,
68847
+ "output": 0,
68848
+ "cacheRead": 0,
68849
+ "cacheWrite": 0
68850
+ },
68851
+ "contextWindow": 262144,
68852
+ "maxTokens": 131072,
68853
+ "thinking": {
68854
+ "mode": "budget",
68855
+ "minLevel": "minimal",
68856
+ "maxLevel": "xhigh"
68857
+ }
68632
68858
  }
68633
68859
  },
68634
68860
  "opengateway": {
@@ -95021,4 +95247,4 @@
95021
95247
  }
95022
95248
  }
95023
95249
  }
95024
- }
95250
+ }
@@ -856,44 +856,41 @@ export interface OpenCodeModelManagerConfig {
856
856
  }
857
857
 
858
858
  function openCodeModelManagerOptions(
859
- providerId: "opencode-go" | "opencode-zen" | "commandcode-goat",
859
+ providerId: "opencode-go" | "opencode-zen",
860
860
  defaultBaseUrl: string,
861
861
  config?: OpenCodeModelManagerConfig,
862
- ): ModelManagerOptions<"openai-completions"> {
862
+ ): ModelManagerOptions<Api> {
863
863
  const apiKey = config?.apiKey;
864
864
  const baseUrl = config?.baseUrl ?? defaultBaseUrl;
865
- const references =
866
- providerId === "opencode-go" ? createBundledReferenceMap<"openai-completions">(providerId) : undefined;
865
+ const references = createBundledReferenceMap<Api>(providerId);
867
866
  return {
868
867
  providerId,
869
868
  ...(apiKey && {
870
869
  fetchDynamicModels: () =>
871
- fetchOpenAICompatibleModels({
870
+ fetchOpenAICompatibleModels<Api>({
872
871
  api: "openai-completions",
873
872
  provider: providerId,
874
873
  baseUrl,
875
874
  apiKey,
876
- ...(providerId === "opencode-go" && {
877
- mapModel: (entry, defaults) => {
878
- const reference = references?.get(defaults.id);
879
- const model = mapWithBundledReference(entry, defaults, reference);
880
- return applyOpenCodeGoOfficialMetadata(model);
881
- },
882
- }),
875
+ mapModel: (entry, defaults) => {
876
+ const model = mapWithBundledReference(entry, defaults, references.get(defaults.id));
877
+ // Discovery uses /v1/models, but the Anthropic client appends
878
+ // /v1/messages itself. Preserve the configured origin, not /v1/v1.
879
+ if (model.api === "anthropic-messages") {
880
+ model.baseUrl = model.baseUrl.replace(/\/v1\/?$/u, "");
881
+ }
882
+ return providerId === "opencode-go" ? applyOpenCodeGoOfficialMetadata(model) : model;
883
+ },
883
884
  }),
884
885
  }),
885
886
  };
886
887
  }
887
888
 
888
- export function opencodeZenModelManagerOptions(
889
- config?: OpenCodeModelManagerConfig,
890
- ): ModelManagerOptions<"openai-completions"> {
889
+ export function opencodeZenModelManagerOptions(config?: OpenCodeModelManagerConfig): ModelManagerOptions<Api> {
891
890
  return openCodeModelManagerOptions("opencode-zen", "https://opencode.ai/zen/v1", config);
892
891
  }
893
892
 
894
- export function opencodeGoModelManagerOptions(
895
- config?: OpenCodeModelManagerConfig,
896
- ): ModelManagerOptions<"openai-completions"> {
893
+ export function opencodeGoModelManagerOptions(config?: OpenCodeModelManagerConfig): ModelManagerOptions<Api> {
897
894
  return openCodeModelManagerOptions("opencode-go", "https://opencode.ai/zen/go/v1", config);
898
895
  }
899
896
 
@@ -2378,7 +2375,9 @@ function createOpenCodeApiResolution(
2378
2375
  }
2379
2376
 
2380
2377
  const OPENCODE_GO_BASE_PATH = "https://opencode.ai/zen/go";
2381
- const OPENCODE_ZEN_API_RESOLUTION = createOpenCodeApiResolution("https://opencode.ai/zen");
2378
+ const OPENCODE_ZEN_API_RESOLUTION = createOpenCodeApiResolution("https://opencode.ai/zen", {
2379
+ "union-alpha": "anthropic-messages",
2380
+ });
2382
2381
  const OPENCODE_GO_CHAT_COMPLETIONS_MODEL_IDS = [
2383
2382
  "deepseek-v4-flash",
2384
2383
  "deepseek-v4-flash-vision-exp",
@@ -2401,6 +2400,7 @@ const OPENCODE_GO_MESSAGES_MODEL_IDS = [
2401
2400
  "qwen3.7-max",
2402
2401
  "qwen3.7-plus",
2403
2402
  "qwen3.8-flash",
2403
+ "union-alpha",
2404
2404
  ] as const;
2405
2405
  const OPENCODE_GO_API_OVERRIDES: Readonly<Record<string, Api>> = {
2406
2406
  ...Object.fromEntries(OPENCODE_GO_CHAT_COMPLETIONS_MODEL_IDS.map(id => [id, "openai-completions"])),
@@ -2658,6 +2658,14 @@ interface OpenCodeGoOfficialModelMetadata {
2658
2658
  }
2659
2659
 
2660
2660
  const OPENCODE_GO_OFFICIAL_MODELS: Readonly<Record<string, OpenCodeGoOfficialModelMetadata>> = {
2661
+ "union-alpha": {
2662
+ name: "Union Alpha Free",
2663
+ contextWindow: 262_144,
2664
+ maxTokens: 131_072,
2665
+ input: ["text", "image"],
2666
+ reasoning: true,
2667
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
2668
+ },
2661
2669
  "deepseek-v4-flash": {
2662
2670
  name: "DeepSeek V4 Flash",
2663
2671
  contextWindow: 1_000_000,
@@ -107,7 +107,7 @@ export interface CpaToolAliasRestoreFailure {
107
107
  */
108
108
  export declare function parseCpaToolAliasRestoreFailure(error: unknown): CpaToolAliasRestoreFailure | undefined;
109
109
  export declare function isCpaToolAliasRestoreFailure(error: unknown): boolean;
110
- export declare const claudeCodeVersion = "2.1.273";
110
+ export declare const claudeCodeVersion = "2.1.280";
111
111
  export declare const claudeCodeEntrypoint = "sdk-cli";
112
112
  export declare const claudeToolPrefix: string;
113
113
  export declare const claudeCodeSystemInstruction = "You are a Claude agent, built on Anthropic's Claude Agent SDK.";
@@ -26,6 +26,7 @@ import {
26
26
  PROVIDER_SAFETY_STOP_ADAPTER_CAPABILITY,
27
27
  } from "../adapter-internals/provider-safety-stop";
28
28
  import {
29
+ getMiniMaxThinkingMode,
29
30
  hasOpus47ApiRestrictions,
30
31
  mapEffortToAnthropicAdaptiveEffort,
31
32
  supportsAnthropicAdaptiveThinkingDisplay as supportsAdaptiveThinkingDisplay,
@@ -833,7 +834,7 @@ function getCacheControl(
833
834
  }
834
835
 
835
836
  // Stealth mode: Mimic Anthropic Code headers and tool prefixing.
836
- export const claudeCodeVersion = "2.1.273";
837
+ export const claudeCodeVersion = "2.1.280";
837
838
  export const claudeCodeEntrypoint = "sdk-cli";
838
839
  export const claudeToolPrefix: string = "proxy_";
839
840
  export const claudeCodeSystemInstruction = "You are a Claude agent, built on Anthropic's Claude Agent SDK.";
@@ -3610,7 +3611,14 @@ function buildParams(
3610
3611
  );
3611
3612
  }
3612
3613
 
3613
- if (model.reasoning) {
3614
+ const miniMaxMode = getMiniMaxThinkingMode(model, baseUrl);
3615
+ if (model.reasoning && miniMaxMode === "toggle") {
3616
+ // MiniMax's Messages endpoint defaults to off and only supports a
3617
+ // switch. Claude budget_tokens/output_config.effort do not apply.
3618
+ if (options?.thinkingEnabled !== undefined) {
3619
+ params.thinking = { type: options.thinkingEnabled ? "adaptive" : "disabled" };
3620
+ }
3621
+ } else if (model.reasoning && miniMaxMode !== "always-on") {
3614
3622
  if (options?.thinkingEnabled) {
3615
3623
  const mode = model.thinking?.mode;
3616
3624
  const requestedEffort = options.reasoning;
@@ -73,6 +73,8 @@ export declare function createCursorMessageQueueForTest(onError?: (error: unknow
73
73
  };
74
74
  /** Exported for direct regression coverage of the JSON-safety boundary. */
75
75
  export declare function cursorJsonSafeValueForTest(value: unknown): unknown;
76
+ /** Exported for direct regression coverage of the Cursor serialization boundary. */
77
+ export declare function cursorJsonSafeStringifyForTest(value: unknown): string;
76
78
  export declare function buildNativeToolCallBlock(toolCall: Record<string, unknown>, callId: string, index: number): ToolCallState | null;
77
79
  /** Derive prompt usage from Cursor's whole-conversation checkpoint total. */
78
80
  export declare function finalizeCursorUsage(output: AssistantMessage, usageState: UsageState): void;
@@ -103,6 +105,14 @@ export declare function finalizeCursorUsageForTest(usedTokens: number, outputTok
103
105
  export declare function buildCursorSystemPromptJsons(systemPrompt: readonly string[] | undefined, modelId?: string): string[];
104
106
  /** Exported for regression coverage of the tool usage-cache identity boundary. */
105
107
  export declare function buildCursorUsageToolsKeyForTest(tools: Tool[]): string;
108
+ /** Exported for regression coverage of the generic tool-schema wire boundary. */
109
+ export declare function buildCursorWireToolIdentitiesForTest(tools: Tool[]): Array<{
110
+ name: string;
111
+ description: string;
112
+ inputSchema: JsonValue;
113
+ }>;
114
+ /** Exported for regression coverage of lossless conversation identity hashing. */
115
+ export declare function hashCursorConversationValueForTest(value: unknown): string;
106
116
  /** Exported for tests: decodes Cursor history blobs built from conversation messages. */
107
117
  export declare function buildCursorHistoryForTest(messages: Message[]): {
108
118
  rootPromptMessagesJson: unknown[];