@prestyj/ai 5.29.0 → 5.29.1

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
@@ -65,7 +65,8 @@ __export(index_exports, {
65
65
  toAnthropicMessages: () => toAnthropicMessages,
66
66
  toOpenAIMessages: () => toOpenAIMessages,
67
67
  toWellFormedText: () => toWellFormedText,
68
- toolCallNameRuleFor: () => toolCallNameRuleFor
68
+ toolCallNameRuleFor: () => toolCallNameRuleFor,
69
+ usesResponsesLite: () => usesResponsesLite
69
70
  });
70
71
  module.exports = __toCommonJS(index_exports);
71
72
 
@@ -2428,7 +2429,7 @@ async function* runStream2(options) {
2428
2429
  ...options.thinking && !usesThinkingParam && !isKimiK3 && !isKimiK27 && !isLocal ? { reasoning_effort: toOpenAIReasoningEffort(options.thinking, options.model) } : {},
2429
2430
  ...options.tools?.length ? {
2430
2431
  tools: toOpenAITools(options.tools, {
2431
- strict: supportsStrictToolSampling(options.provider)
2432
+ strict: supportsStrictToolSampling(options.provider) && (options.strictTools ?? true)
2432
2433
  })
2433
2434
  } : {},
2434
2435
  ...options.toolChoice && options.tools?.length ? { tool_choice: toOpenAIToolChoice(options.toolChoice) } : {},
@@ -2946,6 +2947,7 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
2946
2947
  const downgraded = downgradeUnsupportedVideos(downgradedImages, options.supportsVideo);
2947
2948
  const { system, input } = toCodexInput(downgraded, { supportsImages: options.supportsImages });
2948
2949
  const responsesLite = usesResponsesLite(options.model);
2950
+ const liteShape = options.responsesLite ?? responsesLite;
2949
2951
  const body = {
2950
2952
  model: options.model,
2951
2953
  store: false,
@@ -2953,11 +2955,11 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
2953
2955
  instructions: system,
2954
2956
  input,
2955
2957
  tool_choice: toCodexToolChoice(options.toolChoice, options.tools),
2956
- parallel_tool_calls: !responsesLite,
2958
+ parallel_tool_calls: !liteShape,
2957
2959
  include: ["reasoning.encrypted_content"]
2958
2960
  };
2959
2961
  if (options.tools?.length) {
2960
- body.tools = toCodexTools(options.tools);
2962
+ body.tools = toCodexTools(options.tools, options.strictTools ?? true);
2961
2963
  }
2962
2964
  body.prompt_cache_key = normalizePromptCacheKey(options.promptCacheKey ?? "ezcoder");
2963
2965
  if (options.temperature != null && !options.thinking) {
@@ -2969,7 +2971,7 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
2969
2971
  // `ultra` is a client orchestration preset, not a Codex API effort.
2970
2972
  effort: options.thinking === "ultra" ? "max" : options.thinking ?? (responsesLite ? "low" : "none"),
2971
2973
  summary: "auto",
2972
- ...responsesLite ? { context: "all_turns" } : {}
2974
+ ...liteShape ? { context: "all_turns" } : {}
2973
2975
  };
2974
2976
  if (responsesLite) {
2975
2977
  body.text = { verbosity: "low" };
@@ -2981,10 +2983,8 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
2981
2983
  "OpenAI-Beta": "responses=experimental",
2982
2984
  originator: responsesLite ? "codex_cli_rs" : "ezcoder",
2983
2985
  "User-Agent": responsesLite ? `codex_cli_rs/${CODEX_CLIENT_VERSION}` : `ezcoder (${import_node_os.default.platform()} ${import_node_os.default.release()}; ${import_node_os.default.arch()})`,
2984
- ...responsesLite ? {
2985
- version: CODEX_CLIENT_VERSION,
2986
- "X-OpenAI-Internal-Codex-Responses-Lite": "true"
2987
- } : {}
2986
+ ...responsesLite ? { version: CODEX_CLIENT_VERSION } : {},
2987
+ ...liteShape ? { "X-OpenAI-Internal-Codex-Responses-Lite": "true" } : {}
2988
2988
  };
2989
2989
  if (options.accountId) {
2990
2990
  headers["chatgpt-account-id"] = options.accountId;
@@ -3448,15 +3448,17 @@ function toCodexInput(messages, options) {
3448
3448
  }
3449
3449
  return { system, input };
3450
3450
  }
3451
- function toCodexTools(tools) {
3451
+ function toCodexTools(tools, strictTools) {
3452
3452
  return tools.map((tool) => {
3453
3453
  let parameters = resolveToolSchema(tool);
3454
3454
  let strict = null;
3455
- try {
3456
- parameters = makeStrictToolSchema(parameters);
3457
- strict = true;
3458
- } catch (error) {
3459
- if (!(error instanceof UnsupportedStrictSchemaError)) throw error;
3455
+ if (strictTools) {
3456
+ try {
3457
+ parameters = makeStrictToolSchema(parameters);
3458
+ strict = true;
3459
+ } catch (error) {
3460
+ if (!(error instanceof UnsupportedStrictSchemaError)) throw error;
3461
+ }
3460
3462
  }
3461
3463
  return {
3462
3464
  type: "function",
@@ -3693,6 +3695,17 @@ function stripUnsupportedSchemaFields(value) {
3693
3695
  }
3694
3696
  delete value.$schema;
3695
3697
  delete value.additionalProperties;
3698
+ for (const [key, target, step] of [
3699
+ ["exclusiveMinimum", "minimum", 1],
3700
+ ["exclusiveMaximum", "maximum", -1]
3701
+ ]) {
3702
+ const bound = value[key];
3703
+ if (bound === void 0) continue;
3704
+ delete value[key];
3705
+ if (typeof bound === "number" && value[target] === void 0) {
3706
+ value[target] = value.type === "integer" ? bound + step : bound;
3707
+ }
3708
+ }
3696
3709
  for (const item of Object.values(value)) {
3697
3710
  if (isJsonObject(item) || Array.isArray(item)) {
3698
3711
  stripUnsupportedSchemaFields(item);
@@ -4837,6 +4850,7 @@ function registerPalsuProvider(config) {
4837
4850
  toAnthropicMessages,
4838
4851
  toOpenAIMessages,
4839
4852
  toWellFormedText,
4840
- toolCallNameRuleFor
4853
+ toolCallNameRuleFor,
4854
+ usesResponsesLite
4841
4855
  });
4842
4856
  //# sourceMappingURL=index.cjs.map