@kenkaiiii/gg-ai 5.74.3 → 5.75.0

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/index.js CHANGED
@@ -443,10 +443,22 @@ function zodToJsonSchema(schema) {
443
443
  if (cached) return cached;
444
444
  const jsonSchema = z.toJSONSchema(schema);
445
445
  const { $schema: _schema, ...rest } = jsonSchema;
446
- const normalized = normalizeRootForAnthropic(rest);
446
+ const normalized = normalizeRootForAnthropic(stripNoOpKeywords(rest));
447
447
  schemaCache.set(schema, normalized);
448
448
  return normalized;
449
449
  }
450
+ function stripNoOpKeywords(node) {
451
+ if (Array.isArray(node)) return node.map(stripNoOpKeywords);
452
+ if (node === null || typeof node !== "object") return node;
453
+ const out = {};
454
+ for (const [key, value] of Object.entries(node)) {
455
+ if (key === "maximum" && value === Number.MAX_SAFE_INTEGER) continue;
456
+ if (key === "minimum" && value === Number.MIN_SAFE_INTEGER) continue;
457
+ if (key === "additionalProperties" && value === false) continue;
458
+ out[key] = stripNoOpKeywords(value);
459
+ }
460
+ return out;
461
+ }
450
462
  function resolveToolSchema(tool) {
451
463
  const schema = tool.rawInputSchema ?? zodToJsonSchema(tool.parameters);
452
464
  if (schema.type === "object" && schema.properties === void 0) {
@@ -1221,16 +1233,20 @@ function toAnthropicToolChoice(choice) {
1221
1233
  return { type: "tool", name: choice.name };
1222
1234
  }
1223
1235
  function isAdaptiveThinkingModel(model) {
1224
- return /opus-5|opus-4[-.]8|opus-4[-.]7|opus-4[-.]6|sonnet-5|fable-5|mythos-5/.test(model);
1236
+ return /opus-5|opus-4[-.]8|opus-4[-.]7|opus-4[-.]6|sonnet-5|haiku-5|fable-5|mythos-5/.test(model);
1225
1237
  }
1226
1238
  function toAnthropicThinking(level, maxTokens, model) {
1227
1239
  if (isAdaptiveThinkingModel(model)) {
1228
1240
  let effort = level;
1229
- if (effort === "xhigh" && !/opus-5|opus-4-8|opus-4-7|sonnet-5[-.]5/.test(model)) {
1241
+ if (effort === "xhigh" && !/opus-5|opus-4-8|opus-4-7|sonnet-5[-.]5|haiku-5[-.]5/.test(model)) {
1230
1242
  effort = "high";
1231
1243
  }
1232
1244
  return {
1233
- thinking: { type: "adaptive" },
1245
+ // `display` defaults to "omitted" on Fable/Mythos 5.x, Opus 5.x/4.8/4.7,
1246
+ // Sonnet 5.x and Haiku 5.5: the model still thinks (and bills for it) but
1247
+ // streams empty thinking blocks, so the app shows no reasoning at all.
1248
+ // "summarized" opts back in; on Opus/Sonnet 4.6 it is already the default.
1249
+ thinking: { type: "adaptive", display: "summarized" },
1234
1250
  maxTokens,
1235
1251
  outputConfig: { effort }
1236
1252
  };
@@ -2792,7 +2808,7 @@ function extractRequestIdFromMessage(message) {
2792
2808
 
2793
2809
  // src/providers/openai-codex.ts
2794
2810
  var DEFAULT_BASE_URL = "https://chatgpt.com/backend-api";
2795
- var CODEX_CLIENT_VERSION = "0.159.1";
2811
+ var CODEX_CLIENT_VERSION = "0.161.0";
2796
2812
  var CODEX_REQUEST_COMPRESSION_MIN_BYTES = 16 * 1024;
2797
2813
  var zstdInitPromise;
2798
2814
  async function encodeCodexRequest(body) {
@@ -2980,6 +2996,7 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
2980
2996
  let outputTokens = 0;
2981
2997
  let cacheRead = 0;
2982
2998
  let cacheWrite = 0;
2999
+ let thinkingTextEmitted = false;
2983
3000
  const diagStart = Date.now();
2984
3001
  const diagSeen = /* @__PURE__ */ new Set();
2985
3002
  for await (const event of parseSSE(response.body)) {
@@ -3057,9 +3074,17 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
3057
3074
  }
3058
3075
  }
3059
3076
  }
3077
+ if (type === "response.reasoning_summary_part.added") {
3078
+ if (options.thinking && thinkingTextEmitted) {
3079
+ yield { type: "thinking_delta", text: "\n\n" };
3080
+ }
3081
+ }
3060
3082
  if (type === "response.reasoning_summary_text.delta" || type === "response.reasoning_summary.delta" || type === "response.reasoning_text.delta" || type === "response.reasoning.delta") {
3061
3083
  const delta = event.delta;
3062
- if (options.thinking) yield { type: "thinking_delta", text: delta };
3084
+ if (options.thinking && delta) {
3085
+ thinkingTextEmitted = true;
3086
+ yield { type: "thinking_delta", text: delta };
3087
+ }
3063
3088
  }
3064
3089
  if (type === "response.output_item.added") {
3065
3090
  const item = event.item;
@@ -4220,7 +4245,7 @@ providerRegistry.register("huggingface", {
4220
4245
  // Hugging Face Inference Providers router — one HF token (hf.co/settings/tokens,
4221
4246
  // "Make calls to Inference Providers" permission) routes to whichever hosted
4222
4247
  // backend serves each open model. Chat Completions-compatible; model ids are
4223
- // Hub repo paths ("Qwen/Qwen3-Coder-480B-A35B-Instruct"), optionally with an
4248
+ // Hub repo paths ("moonshotai/Kimi-K2.7-Code"), optionally with an
4224
4249
  // ":auto"/":fastest"/":cheapest" provider-selection suffix. Billing follows
4225
4250
  // each backend's per-token rates on the HF account (small free tier).
4226
4251
  stream: (options) => streamOpenAI({