@kenkaiiii/gg-ai 5.24.0 → 5.26.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.cjs CHANGED
@@ -42,6 +42,7 @@ __export(index_exports, {
42
42
  formatErrorForDisplay: () => formatErrorForDisplay,
43
43
  isHardBillingMessage: () => isHardBillingMessage,
44
44
  isUsageLimitError: () => isUsageLimitError,
45
+ localWireModelId: () => localWireModelId,
45
46
  palsuAssistantMessage: () => palsuAssistantMessage,
46
47
  palsuText: () => palsuText,
47
48
  palsuThinking: () => palsuThinking,
@@ -1161,6 +1162,10 @@ function toOpenAIToolChoice(choice) {
1161
1162
  if (choice === "required") return "required";
1162
1163
  return { type: "function", function: { name: choice.name } };
1163
1164
  }
1165
+ function toLocalReasoningEffort(level) {
1166
+ if (level === "max" || level === "ultra" || level === "xhigh") return "max";
1167
+ return level;
1168
+ }
1164
1169
  function toOpenAIReasoningEffort(level, model) {
1165
1170
  const effort = level === "max" || level === "ultra" ? "xhigh" : level;
1166
1171
  if (model.startsWith("fugu") && (effort === "low" || effort === "medium")) {
@@ -1958,6 +1963,7 @@ async function* runStream2(options) {
1958
1963
  const useStreaming = options.streaming !== false;
1959
1964
  const endpointKey = reasoningFieldKey(providerName, options.baseUrl, options.model);
1960
1965
  const client = createClient2(options);
1966
+ const isLocal = options.provider === "local";
1961
1967
  const isKimiK3 = options.provider === "moonshot" && options.model === "kimi-k3";
1962
1968
  const isManagedKimiK3 = isKimiK3 && options.baseUrl?.replace(/\/+$/, "").endsWith("/coding/v1") === true;
1963
1969
  const k3Effort = options.thinking ? toKimiK3Effort(options.thinking) : void 0;
@@ -1993,7 +1999,7 @@ async function* runStream2(options) {
1993
1999
  ...effectiveTemp != null && !options.thinking && !hasFixedKimiSampling ? { temperature: effectiveTemp } : {},
1994
2000
  ...options.topP != null && !hasFixedKimiSampling ? { top_p: options.topP } : {},
1995
2001
  ...options.stop ? { stop: options.stop } : {},
1996
- ...options.thinking && !usesThinkingParam && !isKimiK3 && !isKimiK27 ? { reasoning_effort: toOpenAIReasoningEffort(options.thinking, options.model) } : {},
2002
+ ...options.thinking && !usesThinkingParam && !isKimiK3 && !isKimiK27 && !isLocal ? { reasoning_effort: toOpenAIReasoningEffort(options.thinking, options.model) } : {},
1997
2003
  ...options.tools?.length ? { tools: toOpenAITools(options.tools) } : {},
1998
2004
  ...options.toolChoice && options.tools?.length ? { tool_choice: toOpenAIToolChoice(options.toolChoice) } : {},
1999
2005
  ...useStreaming ? { stream_options: { include_usage: true } } : {}
@@ -2007,6 +2013,11 @@ async function* runStream2(options) {
2007
2013
  paramsAny.prompt_cache_retention = "24h";
2008
2014
  }
2009
2015
  }
2016
+ if (isLocal && options.thinking) {
2017
+ params.reasoning_effort = toLocalReasoningEffort(
2018
+ options.thinking
2019
+ );
2020
+ }
2010
2021
  if (options.provider === "openai" && options.serviceTier) {
2011
2022
  params.service_tier = options.serviceTier;
2012
2023
  }
@@ -3568,6 +3579,28 @@ providerRegistry.register("minimax", {
3568
3579
  serverTools: void 0
3569
3580
  })
3570
3581
  });
3582
+ function localWireModelId(id) {
3583
+ const match = /^local\/[^/]+\/(.+)$/.exec(id);
3584
+ return match?.[1] ?? id;
3585
+ }
3586
+ providerRegistry.register("local", {
3587
+ // Locally hosted OpenAI-compatible servers (Ollama, LM Studio, llama.cpp,
3588
+ // vLLM). There is no default endpoint: the baseUrl comes from the endpoint
3589
+ // credential the discovery layer wrote, so a missing one is a wiring bug, not
3590
+ // something to paper over with a guess at someone else's port.
3591
+ stream: (options) => {
3592
+ if (!options.baseUrl) {
3593
+ throw new GGAIError(
3594
+ "Local provider requires a baseUrl (e.g. http://127.0.0.1:11434/v1). No local endpoint was resolved for this model \u2014 re-scan for local models."
3595
+ );
3596
+ }
3597
+ return streamOpenAI({
3598
+ ...options,
3599
+ model: localWireModelId(options.model),
3600
+ webSearch: false
3601
+ });
3602
+ }
3603
+ });
3571
3604
  function stream(options) {
3572
3605
  const entry = providerRegistry.get(options.provider);
3573
3606
  if (!entry) {
@@ -3972,6 +4005,7 @@ function registerPalsuProvider(config) {
3972
4005
  formatErrorForDisplay,
3973
4006
  isHardBillingMessage,
3974
4007
  isUsageLimitError,
4008
+ localWireModelId,
3975
4009
  palsuAssistantMessage,
3976
4010
  palsuText,
3977
4011
  palsuThinking,