@code-yeongyu/senpi 2026.7.24 → 2026.7.25-2

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 (158) hide show
  1. package/CHANGELOG.md +32 -1
  2. package/dist/beta/omo-local-update.d.ts +207 -0
  3. package/dist/beta/omo-local-update.d.ts.map +1 -0
  4. package/dist/beta/omo-local-update.js +708 -0
  5. package/dist/beta/omo-local-update.js.map +1 -0
  6. package/dist/core/agent-session.d.ts +13 -0
  7. package/dist/core/agent-session.d.ts.map +1 -1
  8. package/dist/core/agent-session.js +23 -1
  9. package/dist/core/agent-session.js.map +1 -1
  10. package/dist/core/extensions/builtin/config-reload/index.d.ts.map +1 -1
  11. package/dist/core/extensions/builtin/config-reload/index.js +20 -17
  12. package/dist/core/extensions/builtin/config-reload/index.js.map +1 -1
  13. package/dist/core/extensions/builtin/config-reload/log.d.ts +4 -1
  14. package/dist/core/extensions/builtin/config-reload/log.d.ts.map +1 -1
  15. package/dist/core/extensions/builtin/config-reload/log.js +3 -0
  16. package/dist/core/extensions/builtin/config-reload/log.js.map +1 -1
  17. package/dist/core/extensions/builtin/config-reload/routine-settings.d.ts +15 -0
  18. package/dist/core/extensions/builtin/config-reload/routine-settings.d.ts.map +1 -0
  19. package/dist/core/extensions/builtin/config-reload/routine-settings.js +102 -0
  20. package/dist/core/extensions/builtin/config-reload/routine-settings.js.map +1 -0
  21. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts +48 -0
  22. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -1
  23. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +88 -64
  24. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
  25. package/dist/core/extensions/builtin/websearch/index.d.ts.map +1 -1
  26. package/dist/core/extensions/builtin/websearch/index.js +2 -4
  27. package/dist/core/extensions/builtin/websearch/index.js.map +1 -1
  28. package/dist/core/extensions/builtin/websearch/websearch/config.d.ts.map +1 -1
  29. package/dist/core/extensions/builtin/websearch/websearch/config.js +4 -1
  30. package/dist/core/extensions/builtin/websearch/websearch/config.js.map +1 -1
  31. package/dist/core/extensions/builtin/websearch/websearch/native.d.ts.map +1 -1
  32. package/dist/core/extensions/builtin/websearch/websearch/native.js +2 -4
  33. package/dist/core/extensions/builtin/websearch/websearch/native.js.map +1 -1
  34. package/dist/core/extensions/builtin/websearch/websearch/renderers.d.ts.map +1 -1
  35. package/dist/core/extensions/builtin/websearch/websearch/renderers.js +20 -8
  36. package/dist/core/extensions/builtin/websearch/websearch/renderers.js.map +1 -1
  37. package/dist/core/extensions/builtin/websearch/websearch/search.d.ts +6 -1
  38. package/dist/core/extensions/builtin/websearch/websearch/search.d.ts.map +1 -1
  39. package/dist/core/extensions/builtin/websearch/websearch/search.js +15 -11
  40. package/dist/core/extensions/builtin/websearch/websearch/search.js.map +1 -1
  41. package/dist/core/extensions/builtin/websearch/websearch/tool.d.ts.map +1 -1
  42. package/dist/core/extensions/builtin/websearch/websearch/tool.js +5 -10
  43. package/dist/core/extensions/builtin/websearch/websearch/tool.js.map +1 -1
  44. package/dist/core/extensions/builtin/websearch/websearch/types.d.ts +1 -0
  45. package/dist/core/extensions/builtin/websearch/websearch/types.d.ts.map +1 -1
  46. package/dist/core/extensions/builtin/websearch/websearch/types.js.map +1 -1
  47. package/dist/core/extensions/types.d.ts +2 -0
  48. package/dist/core/extensions/types.d.ts.map +1 -1
  49. package/dist/core/extensions/types.js.map +1 -1
  50. package/dist/core/model-resolver.d.ts +1 -0
  51. package/dist/core/model-resolver.d.ts.map +1 -1
  52. package/dist/core/model-resolver.js +13 -3
  53. package/dist/core/model-resolver.js.map +1 -1
  54. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  55. package/dist/core/remote-catalog-provider.js +19 -1
  56. package/dist/core/remote-catalog-provider.js.map +1 -1
  57. package/dist/core/resource-loader.d.ts.map +1 -1
  58. package/dist/core/resource-loader.js +3 -0
  59. package/dist/core/resource-loader.js.map +1 -1
  60. package/dist/core/retry-fallback/controller.d.ts +7 -0
  61. package/dist/core/retry-fallback/controller.d.ts.map +1 -1
  62. package/dist/core/retry-fallback/controller.js +13 -0
  63. package/dist/core/retry-fallback/controller.js.map +1 -1
  64. package/dist/core/settings-manager.d.ts +7 -0
  65. package/dist/core/settings-manager.d.ts.map +1 -1
  66. package/dist/core/settings-manager.js +10 -0
  67. package/dist/core/settings-manager.js.map +1 -1
  68. package/dist/core/thinking-levels.d.ts.map +1 -1
  69. package/dist/core/thinking-levels.js +9 -2
  70. package/dist/core/thinking-levels.js.map +1 -1
  71. package/dist/extensions/llama/provider.d.ts.map +1 -1
  72. package/dist/extensions/llama/provider.js +6 -0
  73. package/dist/extensions/llama/provider.js.map +1 -1
  74. package/dist/modes/interactive/components/custom-message.d.ts +3 -1
  75. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  76. package/dist/modes/interactive/components/custom-message.js +9 -2
  77. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  78. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  79. package/dist/modes/interactive/interactive-mode.js +9 -2
  80. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  81. package/dist/package-manager-cli.d.ts.map +1 -1
  82. package/dist/package-manager-cli.js +11 -0
  83. package/dist/package-manager-cli.js.map +1 -1
  84. package/docs/extensions.md +2 -2
  85. package/docs/settings.md +11 -0
  86. package/examples/extensions/message-renderer.ts +2 -2
  87. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +13 -1
  88. package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
  89. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +3 -0
  90. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts.map +1 -1
  91. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js +2 -0
  92. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -1
  93. package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  94. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  95. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +87 -22
  96. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  97. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts.map +1 -1
  98. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +15 -7
  99. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js.map +1 -1
  100. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +38 -16
  101. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
  102. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.d.ts.map +1 -1
  103. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +9 -2
  104. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js.map +1 -1
  105. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.d.ts.map +1 -1
  106. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +12 -2
  107. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js.map +1 -1
  108. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
  109. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +19 -11
  110. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
  111. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
  112. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +121 -23
  113. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  114. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
  115. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +12 -7
  116. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
  117. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.d.ts.map +1 -1
  118. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +1 -0
  119. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js.map +1 -1
  120. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.d.ts +3 -2
  121. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.d.ts.map +1 -1
  122. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.js +37 -35
  123. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.js.map +1 -1
  124. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts.map +1 -1
  125. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +11 -1
  126. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js.map +1 -1
  127. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +1 -0
  128. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
  129. package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
  130. package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
  131. package/node_modules/@earendil-works/pi-ai/dist/models-store.d.ts +5 -0
  132. package/node_modules/@earendil-works/pi-ai/dist/models-store.d.ts.map +1 -1
  133. package/node_modules/@earendil-works/pi-ai/dist/models-store.js.map +1 -1
  134. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
  135. package/node_modules/@earendil-works/pi-ai/dist/models.js +5 -1
  136. package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
  137. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  138. package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
  139. package/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
  140. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  141. package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  142. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  143. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  144. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  145. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +9 -0
  146. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  147. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  148. package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.d.ts.map +1 -1
  149. package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js +8 -3
  150. package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js.map +1 -1
  151. package/node_modules/@earendil-works/pi-ai/dist/utils/server-fallback-receipt.d.ts +30 -0
  152. package/node_modules/@earendil-works/pi-ai/dist/utils/server-fallback-receipt.d.ts.map +1 -0
  153. package/node_modules/@earendil-works/pi-ai/dist/utils/server-fallback-receipt.js +70 -0
  154. package/node_modules/@earendil-works/pi-ai/dist/utils/server-fallback-receipt.js.map +1 -0
  155. package/node_modules/@earendil-works/pi-ai/package.json +1 -1
  156. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  157. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  158. package/package.json +6 -10
@@ -15,6 +15,87 @@ import { buildCopilotDynamicHeaders, hasCopilotVisionInput } from "./github-copi
15
15
  import { clampOpenAIPromptCacheKey } from "./openai-prompt-cache.js";
16
16
  import { applyExtraBody, buildBaseOptions, clampMaxForOpenAI, OPENAI_COMPLETIONS_RESERVED_BODY_KEYS, } from "./simple-options.js";
17
17
  import { transformMessages } from "./transform-messages.js";
18
+ const KIMI_K3_THINKING_LEVEL_MAP = {
19
+ off: null,
20
+ minimal: null,
21
+ low: "low",
22
+ medium: null,
23
+ high: "high",
24
+ xhigh: null,
25
+ max: "max",
26
+ };
27
+ const DEEPSEEK_THINKING_LEVEL_MAP = {
28
+ minimal: "high",
29
+ low: "high",
30
+ medium: "high",
31
+ high: "high",
32
+ xhigh: "max",
33
+ max: "max",
34
+ };
35
+ const OPENROUTER_DEEPSEEK_THINKING_LEVEL_MAP = {
36
+ minimal: "high",
37
+ low: "high",
38
+ medium: "high",
39
+ high: "high",
40
+ xhigh: "high",
41
+ max: "high",
42
+ };
43
+ const MIMO_THINKING_LEVEL_MAP = {
44
+ minimal: "low",
45
+ low: "low",
46
+ medium: "medium",
47
+ high: "high",
48
+ xhigh: "high",
49
+ max: null,
50
+ };
51
+ const OLLAMA_THINKING_LEVEL_MAP = {
52
+ off: "none",
53
+ minimal: null,
54
+ low: "low",
55
+ medium: "medium",
56
+ high: "high",
57
+ xhigh: null,
58
+ max: "max",
59
+ };
60
+ function getThinkingLevelMap(model, compat) {
61
+ if (model.thinkingLevelMap !== undefined) {
62
+ return model.thinkingLevelMap;
63
+ }
64
+ const id = model.id.toLowerCase();
65
+ const isKimiK3 = id === "k3" || id.startsWith("k3-") || /(?:^|[/:-])kimi-k3(?:$|[/.:_-])/.test(id);
66
+ const isDeepSeek = id.includes("deepseek");
67
+ const isMiMo = /\bmimo\b/.test(id);
68
+ const isGlm52 = /(?:^|[/:-])glm-5\.2(?:$|[/.:_-])/.test(id);
69
+ if (model.provider === "ollama") {
70
+ return OLLAMA_THINKING_LEVEL_MAP;
71
+ }
72
+ if (isKimiK3) {
73
+ return KIMI_K3_THINKING_LEVEL_MAP;
74
+ }
75
+ if (compat.thinkingFormat === "openrouter" && isDeepSeek) {
76
+ return OPENROUTER_DEEPSEEK_THINKING_LEVEL_MAP;
77
+ }
78
+ if ((compat.thinkingFormat === "openai" || compat.thinkingFormat === "openrouter") && isMiMo) {
79
+ return MIMO_THINKING_LEVEL_MAP;
80
+ }
81
+ if (isDeepSeek) {
82
+ return DEEPSEEK_THINKING_LEVEL_MAP;
83
+ }
84
+ if (isGlm52) {
85
+ if (compat.thinkingFormat === "zai") {
86
+ return DEEPSEEK_THINKING_LEVEL_MAP;
87
+ }
88
+ if (compat.thinkingFormat === "openrouter") {
89
+ return { xhigh: "xhigh" };
90
+ }
91
+ return { max: "max" };
92
+ }
93
+ return undefined;
94
+ }
95
+ function resolveReasoningEffort(thinkingLevelMap, effort) {
96
+ const mapped = thinkingLevelMap?.[effort];
97
+ return mapped === undefined ? effort : typeof mapped === "string" ? mapped : undefined;
98
+ }
18
99
  /**
19
100
  * Check if conversation messages contain tool calls or tool results.
20
101
  * This is needed because Anthropic (via proxy) requires the tools param
@@ -497,12 +578,15 @@ export const stream = (model, context, options) => {
497
578
  export const streamSimple = (model, context, options) => {
498
579
  getClientApiKey(model.provider, options?.apiKey, options?.headers);
499
580
  const base = buildBaseOptions(model, context, options, options?.apiKey);
500
- const clampedReasoning = options?.reasoning ? clampThinkingLevel(model, options.reasoning) : undefined;
581
+ const compat = getCompat(model);
582
+ const thinkingLevelMap = getThinkingLevelMap(model, compat);
583
+ const thinkingModel = thinkingLevelMap === model.thinkingLevelMap ? model : { ...model, thinkingLevelMap };
584
+ const clampedReasoning = options?.reasoning ? clampThinkingLevel(thinkingModel, options.reasoning) : undefined;
501
585
  const reasoningEffort = clampedReasoning === "off"
502
586
  ? undefined
503
- : clampedReasoning === "max" && model.thinkingLevelMap?.max !== undefined
587
+ : clampedReasoning === "max" && thinkingLevelMap?.max !== undefined
504
588
  ? "max"
505
- : clampMaxForOpenAI(clampedReasoning, supportsXhigh(model));
589
+ : clampMaxForOpenAI(clampedReasoning, supportsXhigh(thinkingModel));
506
590
  const toolChoice = options?.toolChoice;
507
591
  return stream(model, context, {
508
592
  ...base,
@@ -549,6 +633,7 @@ function buildParams(model, context, options, compat = getCompat(model), cacheRe
549
633
  grammarToolInputProperties,
550
634
  });
551
635
  const cacheControl = getCompatCacheControl(compat, cacheRetention);
636
+ const thinkingLevelMap = getThinkingLevelMap(model, compat);
552
637
  const params = {
553
638
  model: model.id,
554
639
  messages,
@@ -598,9 +683,8 @@ function buildParams(model, context, options, compat = getCompat(model), cacheRe
598
683
  const zaiParams = params;
599
684
  zaiParams.thinking = options?.reasoningEffort ? { type: "enabled", clear_thinking: false } : { type: "disabled" };
600
685
  if (options?.reasoningEffort && compat.supportsReasoningEffort) {
601
- const mappedEffort = model.thinkingLevelMap?.[options.reasoningEffort];
602
- const effort = mappedEffort === undefined ? options.reasoningEffort : mappedEffort;
603
- if (typeof effort === "string") {
686
+ const effort = resolveReasoningEffort(thinkingLevelMap, options.reasoningEffort);
687
+ if (effort !== undefined) {
604
688
  zaiParams.reasoning_effort = effort;
605
689
  }
606
690
  }
@@ -624,10 +708,13 @@ function buildParams(model, context, options, compat = getCompat(model), cacheRe
624
708
  if (options?.reasoningEffort) {
625
709
  params.thinking = { type: "enabled" };
626
710
  if (compat.supportsReasoningEffort) {
627
- params.reasoning_effort = model.thinkingLevelMap?.[options.reasoningEffort] ?? options.reasoningEffort;
711
+ const effort = resolveReasoningEffort(thinkingLevelMap, options.reasoningEffort);
712
+ if (effort !== undefined) {
713
+ params.reasoning_effort = effort;
714
+ }
628
715
  }
629
716
  }
630
- else if (compat.supportsDisabledThinking !== false && model.thinkingLevelMap?.off !== null) {
717
+ else if (compat.supportsDisabledThinking !== false && thinkingLevelMap?.off !== null) {
631
718
  params.thinking = { type: "disabled" };
632
719
  }
633
720
  }
@@ -635,16 +722,17 @@ function buildParams(model, context, options, compat = getCompat(model), cacheRe
635
722
  // OpenRouter normalizes reasoning across providers via a nested reasoning object.
636
723
  const openRouterParams = params;
637
724
  if (options?.reasoningEffort) {
638
- openRouterParams.reasoning = {
639
- effort: model.thinkingLevelMap?.[options.reasoningEffort] ?? options.reasoningEffort,
640
- };
725
+ const effort = resolveReasoningEffort(thinkingLevelMap, options.reasoningEffort);
726
+ if (effort !== undefined) {
727
+ openRouterParams.reasoning = { effort };
728
+ }
641
729
  }
642
- else if (model.thinkingLevelMap?.off !== null) {
643
- openRouterParams.reasoning = { effort: model.thinkingLevelMap?.off ?? "none" };
730
+ else if (thinkingLevelMap?.off !== null) {
731
+ openRouterParams.reasoning = { effort: thinkingLevelMap?.off ?? "none" };
644
732
  }
645
733
  }
646
734
  else if (compat.thinkingFormat === "ant-ling" && model.reasoning && options?.reasoningEffort) {
647
- const effort = model.thinkingLevelMap?.[options.reasoningEffort];
735
+ const effort = thinkingLevelMap?.[options.reasoningEffort];
648
736
  if (typeof effort === "string") {
649
737
  params.reasoning = { effort };
650
738
  }
@@ -653,23 +741,32 @@ function buildParams(model, context, options, compat = getCompat(model), cacheRe
653
741
  const togetherParams = params;
654
742
  togetherParams.reasoning = { enabled: !!options?.reasoningEffort };
655
743
  if (options?.reasoningEffort && compat.supportsReasoningEffort) {
656
- togetherParams.reasoning_effort = model.thinkingLevelMap?.[options.reasoningEffort] ?? options.reasoningEffort;
744
+ const effort = resolveReasoningEffort(thinkingLevelMap, options.reasoningEffort);
745
+ if (effort !== undefined) {
746
+ togetherParams.reasoning_effort = effort;
747
+ }
657
748
  }
658
749
  }
659
750
  else if (compat.thinkingFormat === "string-thinking" && model.reasoning) {
660
751
  if (options?.reasoningEffort) {
661
- params.thinking = model.thinkingLevelMap?.[options.reasoningEffort] ?? options.reasoningEffort;
752
+ const effort = resolveReasoningEffort(thinkingLevelMap, options.reasoningEffort);
753
+ if (effort !== undefined) {
754
+ params.thinking = effort;
755
+ }
662
756
  }
663
- else if (model.thinkingLevelMap?.off !== null) {
664
- params.thinking = model.thinkingLevelMap?.off ?? "none";
757
+ else if (thinkingLevelMap?.off !== null) {
758
+ params.thinking = thinkingLevelMap?.off ?? "none";
665
759
  }
666
760
  }
667
761
  else if (options?.reasoningEffort && model.reasoning && compat.supportsReasoningEffort) {
668
762
  // OpenAI-style reasoning_effort
669
- params.reasoning_effort = model.thinkingLevelMap?.[options.reasoningEffort] ?? options.reasoningEffort;
763
+ const effort = resolveReasoningEffort(thinkingLevelMap, options.reasoningEffort);
764
+ if (effort !== undefined) {
765
+ params.reasoning_effort = effort;
766
+ }
670
767
  }
671
768
  else if (!options?.reasoningEffort && model.reasoning && compat.supportsReasoningEffort) {
672
- const offValue = model.thinkingLevelMap?.off;
769
+ const offValue = thinkingLevelMap?.off;
673
770
  if (typeof offValue === "string") {
674
771
  params.reasoning_effort = offValue;
675
772
  }
@@ -696,14 +793,14 @@ function buildParams(model, context, options, compat = getCompat(model), cacheRe
696
793
  function buildChatTemplateKwargs(model, options, compat) {
697
794
  const kwargs = {};
698
795
  for (const [key, value] of Object.entries(compat.chatTemplateKwargs)) {
699
- const resolved = resolveChatTemplateKwargValue(model, options, value);
796
+ const resolved = resolveChatTemplateKwargValue(model, options, compat, value);
700
797
  if (resolved !== undefined) {
701
798
  kwargs[key] = resolved;
702
799
  }
703
800
  }
704
801
  return Object.keys(kwargs).length > 0 ? kwargs : undefined;
705
802
  }
706
- function resolveChatTemplateKwargValue(model, options, value) {
803
+ function resolveChatTemplateKwargValue(model, options, compat, value) {
707
804
  if (typeof value !== "object" || value === null) {
708
805
  return value;
709
806
  }
@@ -714,7 +811,8 @@ function resolveChatTemplateKwargValue(model, options, value) {
714
811
  if (value.$var === "thinking.enabled") {
715
812
  return !!reasoningEffort;
716
813
  }
717
- const mappedValue = reasoningEffort ? model.thinkingLevelMap?.[reasoningEffort] : model.thinkingLevelMap?.off;
814
+ const thinkingLevelMap = getThinkingLevelMap(model, compat);
815
+ const mappedValue = reasoningEffort ? thinkingLevelMap?.[reasoningEffort] : thinkingLevelMap?.off;
718
816
  return mappedValue === undefined ? reasoningEffort : typeof mappedValue === "string" ? mappedValue : undefined;
719
817
  }
720
818
  function getCompatCacheControl(compat, cacheRetention) {