@cognipeer/agent-sdk 0.8.9 → 0.8.10

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
@@ -4299,7 +4299,7 @@ var LEVEL_DEFAULTS = {
4299
4299
  };
4300
4300
  var VALID_LEVELS = ["minimal", "low", "medium", "high"];
4301
4301
  var VALID_CADENCES = ["off", "every_turn", "after_tool", "on_branch", "initial_then_after_tool"];
4302
- var VALID_EFFORTS = ["minimal", "low", "medium", "high"];
4302
+ var VALID_EFFORTS = ["none", "minimal", "low", "medium", "high"];
4303
4303
  function validateReasoningConfig(input) {
4304
4304
  if (!input) return;
4305
4305
  if (input.level !== void 0 && !VALID_LEVELS.includes(input.level)) {
@@ -8793,12 +8793,19 @@ function parseSSEBlock(block) {
8793
8793
 
8794
8794
  // src/providers/utils/reasoning.ts
8795
8795
  var ANTHROPIC_EFFORT_BUDGET = {
8796
+ // 0 = off. `applyAnthropicReasoning` bails on a falsy budget and emits no
8797
+ // thinking block, which on Anthropic IS off — thinking there is opt-in.
8798
+ none: 0,
8796
8799
  minimal: 1024,
8797
8800
  low: 2048,
8798
8801
  medium: 8192,
8799
8802
  high: 16384
8800
8803
  };
8801
8804
  var GEMINI_EFFORT_BUDGET = {
8805
+ // 0 is Gemini's own documented spelling for "do not think", and unlike
8806
+ // Anthropic it has to be SENT — hence `applyGeminiReasoning` testing for null
8807
+ // rather than falsiness.
8808
+ none: 0,
8802
8809
  minimal: 512,
8803
8810
  low: 1024,
8804
8811
  medium: 4096,
@@ -8874,14 +8881,15 @@ function clampBudget(budget, maxTokens) {
8874
8881
  }
8875
8882
  function normalizeEffort(effort) {
8876
8883
  if (!effort) return void 0;
8877
- const allowed = ["minimal", "low", "medium", "high"];
8884
+ const allowed = ["none", "minimal", "low", "medium", "high"];
8878
8885
  return allowed.includes(effort) ? effort : void 0;
8879
8886
  }
8880
8887
  function resolveBudget(reasoning, effortBudget) {
8888
+ const effort = normalizeEffort(reasoning.effort);
8889
+ if (effort === "none") return 0;
8881
8890
  if (typeof reasoning.budgetTokens === "number" && reasoning.budgetTokens > 0) {
8882
8891
  return Math.floor(reasoning.budgetTokens);
8883
8892
  }
8884
- const effort = normalizeEffort(reasoning.effort);
8885
8893
  if (effort && effortBudget[effort]) return effortBudget[effort];
8886
8894
  return void 0;
8887
8895
  }
@@ -8970,12 +8978,21 @@ var OpenAIProvider = class extends BaseProvider {
8970
8978
  ...config.defaultHeaders,
8971
8979
  ...config.organization ? { "OpenAI-Organization": config.organization } : {}
8972
8980
  };
8981
+ this.responsesApi = config.responsesApi ?? "auto";
8973
8982
  if (config.retry) this.retryPolicy = { ...this.retryPolicy, ...config.retry };
8974
8983
  }
8975
- /** True when the request targets a reasoning model (o-series / gpt-5) so we
8976
- * should route through the Responses API, which exposes `reasoning.effort`
8977
- * and reasoning summaries. Chat Completions silently drops these. */
8984
+ /** True when this request should go to the Responses API rather than Chat
8985
+ * Completions — which exposes `reasoning.effort` and reasoning summaries that
8986
+ * Chat Completions silently drops.
8987
+ *
8988
+ * `auto` (the default) keeps the historical rule: only when the request
8989
+ * carries a reasoning config AND the model name looks like an o-series/gpt-5
8990
+ * model. `never`/`always` let a caller state the answer instead, because the
8991
+ * name check is a guess and the two APIs differ in far more than reasoning —
8992
+ * see `responsesApi` in OpenAIProviderConfig. */
8978
8993
  useResponsesApi(request) {
8994
+ if (this.responsesApi === "never") return false;
8995
+ if (this.responsesApi === "always") return true;
8979
8996
  if (!request.reasoning) return false;
8980
8997
  return isReasoningModel(request.model || this.defaultModel);
8981
8998
  }
@@ -10838,7 +10855,7 @@ function fromNativeProvider(provider, options) {
10838
10855
  if (tools?.length) req.tools = tools;
10839
10856
  if (opts?.extra) req.extra = opts.extra;
10840
10857
  const reasoningOverride = invokeOptions?.reasoning;
10841
- const reasoningCfg = reasoningOverride ?? opts?.reasoning;
10858
+ const reasoningCfg = mergeReasoning(opts?.reasoning, reasoningOverride);
10842
10859
  if (reasoningCfg) req.reasoning = reasoningCfg;
10843
10860
  const tc = invokeOptions?.tool_choice ?? invokeOptions?.toolChoice;
10844
10861
  if (tc && tools?.length) {
@@ -10867,6 +10884,15 @@ function fromNativeProvider(provider, options) {
10867
10884
  return req;
10868
10885
  }
10869
10886
  }
10887
+ function mergeReasoning(base, override) {
10888
+ if (!base) return override;
10889
+ if (!override) return base;
10890
+ const merged = { ...base, ...override };
10891
+ if (base.providerExtras || override.providerExtras) {
10892
+ merged.providerExtras = { ...base.providerExtras, ...override.providerExtras };
10893
+ }
10894
+ return merged;
10895
+ }
10870
10896
  function toUnifiedMessage(msg) {
10871
10897
  const unified = {
10872
10898
  role: msg.role,