@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.d.cts CHANGED
@@ -223,6 +223,15 @@ interface StreamOptions {
223
223
  promptCacheKey?: string;
224
224
  /** OpenAI service tier for latency-sensitive requests. Only sent to first-party OpenAI API calls. */
225
225
  serviceTier?: "auto" | "default" | "flex" | "priority";
226
+ /** Codex endpoint only: send the Responses-Lite request shape (lite header,
227
+ * `parallel_tool_calls: false`, all-turns reasoning context). Unset follows
228
+ * the model family (on for gpt-5.6/gpt-6 models). Lite allows only one tool
229
+ * call per response, so turning it off lets the model batch calls. */
230
+ responsesLite?: boolean;
231
+ /** OpenAI only (Codex and API-key routes): send tools with strict
232
+ * (grammar-constrained) schemas. Default true. Strict calls carry every
233
+ * optional field as null, which costs output tokens and latency per call. */
234
+ strictTools?: boolean;
226
235
  /** OpenAI ChatGPT account ID (from OAuth JWT) for codex endpoint */
227
236
  accountId?: string;
228
237
  /** Stable conversation identity for Codex transport headers. This is distinct from
@@ -685,6 +694,8 @@ declare function toOpenAIMessages(messages: Message[], options?: {
685
694
  reasoningField?: string;
686
695
  }): OpenAI.ChatCompletionMessageParam[];
687
696
 
697
+ declare function usesResponsesLite(model: string): boolean;
698
+
688
699
  /**
689
700
  * Fire a minimal `max_tokens: 1` request that populates the Anthropic prompt
690
701
  * cache with the system prompt + tools prefix, so the first real user turn is
@@ -776,4 +787,4 @@ interface PalsuProviderConfig {
776
787
  */
777
788
  declare function registerPalsuProvider(config?: PalsuProviderConfig): PalsuProviderHandle;
778
789
 
779
- export { type AssistantMessage, type CacheRetention, type ContentPart, type DoneEvent, EZCoderAIError, type ErrorEvent, type ErrorSource, EventStream, type FormattedError, type ImageContent, type Message, type MessageProvenance, type MessageProvenanceKind, type MessageProvenanceSource, type MessageProvenanceVisibility, type PalsuModelConfig, type PalsuModelHandle, type PalsuProviderConfig, type PalsuProviderHandle, type PalsuProviderState, type PalsuResponse, type PalsuResponseFactory, type PreparedContext, type Provider, type ProviderDiagnosticFn, type ProviderEntry, ProviderError, type ProviderStreamFn, REDACTED as REDACTION_MARKER, type RawContent, type RedactionOptions, type ServerToolCall, type ServerToolCallEvent, type ServerToolDefinition, type ServerToolResult, type ServerToolResultEvent, type StopReason, type StreamEvent, type StreamOptions, type StreamResponse, StreamResult, type SystemMessage, TOOL_CALL_NAME_RULES, type TextContent, type TextDeltaEvent, type ThinkingContent, type ThinkingDeltaEvent, type ThinkingLevel, type Tool, type ToolCall, type ToolCallDeltaEvent, type ToolCallDoneEvent, type ToolCallNameRule, type ToolChoice, type ToolResult, type ToolResultContent, type ToolResultMessage, type Usage, type UserMessage, type VideoContent, clampProviderContextImages, classifyProviderError, dropInvalidToolCalls, environmentSecrets, formatError, formatErrorForDisplay, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, isValidToolCallName, localWireModelId, palsuAssistantMessage, palsuText, palsuThinking, palsuToolCall, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, resolveToolSchema, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText, toolCallNameRuleFor };
790
+ export { type AssistantMessage, type CacheRetention, type ContentPart, type DoneEvent, EZCoderAIError, type ErrorEvent, type ErrorSource, EventStream, type FormattedError, type ImageContent, type Message, type MessageProvenance, type MessageProvenanceKind, type MessageProvenanceSource, type MessageProvenanceVisibility, type PalsuModelConfig, type PalsuModelHandle, type PalsuProviderConfig, type PalsuProviderHandle, type PalsuProviderState, type PalsuResponse, type PalsuResponseFactory, type PreparedContext, type Provider, type ProviderDiagnosticFn, type ProviderEntry, ProviderError, type ProviderStreamFn, REDACTED as REDACTION_MARKER, type RawContent, type RedactionOptions, type ServerToolCall, type ServerToolCallEvent, type ServerToolDefinition, type ServerToolResult, type ServerToolResultEvent, type StopReason, type StreamEvent, type StreamOptions, type StreamResponse, StreamResult, type SystemMessage, TOOL_CALL_NAME_RULES, type TextContent, type TextDeltaEvent, type ThinkingContent, type ThinkingDeltaEvent, type ThinkingLevel, type Tool, type ToolCall, type ToolCallDeltaEvent, type ToolCallDoneEvent, type ToolCallNameRule, type ToolChoice, type ToolResult, type ToolResultContent, type ToolResultMessage, type Usage, type UserMessage, type VideoContent, clampProviderContextImages, classifyProviderError, dropInvalidToolCalls, environmentSecrets, formatError, formatErrorForDisplay, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, isValidToolCallName, localWireModelId, palsuAssistantMessage, palsuText, palsuThinking, palsuToolCall, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, resolveToolSchema, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText, toolCallNameRuleFor, usesResponsesLite };
package/dist/index.d.ts CHANGED
@@ -223,6 +223,15 @@ interface StreamOptions {
223
223
  promptCacheKey?: string;
224
224
  /** OpenAI service tier for latency-sensitive requests. Only sent to first-party OpenAI API calls. */
225
225
  serviceTier?: "auto" | "default" | "flex" | "priority";
226
+ /** Codex endpoint only: send the Responses-Lite request shape (lite header,
227
+ * `parallel_tool_calls: false`, all-turns reasoning context). Unset follows
228
+ * the model family (on for gpt-5.6/gpt-6 models). Lite allows only one tool
229
+ * call per response, so turning it off lets the model batch calls. */
230
+ responsesLite?: boolean;
231
+ /** OpenAI only (Codex and API-key routes): send tools with strict
232
+ * (grammar-constrained) schemas. Default true. Strict calls carry every
233
+ * optional field as null, which costs output tokens and latency per call. */
234
+ strictTools?: boolean;
226
235
  /** OpenAI ChatGPT account ID (from OAuth JWT) for codex endpoint */
227
236
  accountId?: string;
228
237
  /** Stable conversation identity for Codex transport headers. This is distinct from
@@ -685,6 +694,8 @@ declare function toOpenAIMessages(messages: Message[], options?: {
685
694
  reasoningField?: string;
686
695
  }): OpenAI.ChatCompletionMessageParam[];
687
696
 
697
+ declare function usesResponsesLite(model: string): boolean;
698
+
688
699
  /**
689
700
  * Fire a minimal `max_tokens: 1` request that populates the Anthropic prompt
690
701
  * cache with the system prompt + tools prefix, so the first real user turn is
@@ -776,4 +787,4 @@ interface PalsuProviderConfig {
776
787
  */
777
788
  declare function registerPalsuProvider(config?: PalsuProviderConfig): PalsuProviderHandle;
778
789
 
779
- export { type AssistantMessage, type CacheRetention, type ContentPart, type DoneEvent, EZCoderAIError, type ErrorEvent, type ErrorSource, EventStream, type FormattedError, type ImageContent, type Message, type MessageProvenance, type MessageProvenanceKind, type MessageProvenanceSource, type MessageProvenanceVisibility, type PalsuModelConfig, type PalsuModelHandle, type PalsuProviderConfig, type PalsuProviderHandle, type PalsuProviderState, type PalsuResponse, type PalsuResponseFactory, type PreparedContext, type Provider, type ProviderDiagnosticFn, type ProviderEntry, ProviderError, type ProviderStreamFn, REDACTED as REDACTION_MARKER, type RawContent, type RedactionOptions, type ServerToolCall, type ServerToolCallEvent, type ServerToolDefinition, type ServerToolResult, type ServerToolResultEvent, type StopReason, type StreamEvent, type StreamOptions, type StreamResponse, StreamResult, type SystemMessage, TOOL_CALL_NAME_RULES, type TextContent, type TextDeltaEvent, type ThinkingContent, type ThinkingDeltaEvent, type ThinkingLevel, type Tool, type ToolCall, type ToolCallDeltaEvent, type ToolCallDoneEvent, type ToolCallNameRule, type ToolChoice, type ToolResult, type ToolResultContent, type ToolResultMessage, type Usage, type UserMessage, type VideoContent, clampProviderContextImages, classifyProviderError, dropInvalidToolCalls, environmentSecrets, formatError, formatErrorForDisplay, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, isValidToolCallName, localWireModelId, palsuAssistantMessage, palsuText, palsuThinking, palsuToolCall, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, resolveToolSchema, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText, toolCallNameRuleFor };
790
+ export { type AssistantMessage, type CacheRetention, type ContentPart, type DoneEvent, EZCoderAIError, type ErrorEvent, type ErrorSource, EventStream, type FormattedError, type ImageContent, type Message, type MessageProvenance, type MessageProvenanceKind, type MessageProvenanceSource, type MessageProvenanceVisibility, type PalsuModelConfig, type PalsuModelHandle, type PalsuProviderConfig, type PalsuProviderHandle, type PalsuProviderState, type PalsuResponse, type PalsuResponseFactory, type PreparedContext, type Provider, type ProviderDiagnosticFn, type ProviderEntry, ProviderError, type ProviderStreamFn, REDACTED as REDACTION_MARKER, type RawContent, type RedactionOptions, type ServerToolCall, type ServerToolCallEvent, type ServerToolDefinition, type ServerToolResult, type ServerToolResultEvent, type StopReason, type StreamEvent, type StreamOptions, type StreamResponse, StreamResult, type SystemMessage, TOOL_CALL_NAME_RULES, type TextContent, type TextDeltaEvent, type ThinkingContent, type ThinkingDeltaEvent, type ThinkingLevel, type Tool, type ToolCall, type ToolCallDeltaEvent, type ToolCallDoneEvent, type ToolCallNameRule, type ToolChoice, type ToolResult, type ToolResultContent, type ToolResultMessage, type Usage, type UserMessage, type VideoContent, clampProviderContextImages, classifyProviderError, dropInvalidToolCalls, environmentSecrets, formatError, formatErrorForDisplay, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, isValidToolCallName, localWireModelId, palsuAssistantMessage, palsuText, palsuThinking, palsuToolCall, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, resolveToolSchema, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText, toolCallNameRuleFor, usesResponsesLite };
package/dist/index.js CHANGED
@@ -2357,7 +2357,7 @@ async function* runStream2(options) {
2357
2357
  ...options.thinking && !usesThinkingParam && !isKimiK3 && !isKimiK27 && !isLocal ? { reasoning_effort: toOpenAIReasoningEffort(options.thinking, options.model) } : {},
2358
2358
  ...options.tools?.length ? {
2359
2359
  tools: toOpenAITools(options.tools, {
2360
- strict: supportsStrictToolSampling(options.provider)
2360
+ strict: supportsStrictToolSampling(options.provider) && (options.strictTools ?? true)
2361
2361
  })
2362
2362
  } : {},
2363
2363
  ...options.toolChoice && options.tools?.length ? { tool_choice: toOpenAIToolChoice(options.toolChoice) } : {},
@@ -2875,6 +2875,7 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
2875
2875
  const downgraded = downgradeUnsupportedVideos(downgradedImages, options.supportsVideo);
2876
2876
  const { system, input } = toCodexInput(downgraded, { supportsImages: options.supportsImages });
2877
2877
  const responsesLite = usesResponsesLite(options.model);
2878
+ const liteShape = options.responsesLite ?? responsesLite;
2878
2879
  const body = {
2879
2880
  model: options.model,
2880
2881
  store: false,
@@ -2882,11 +2883,11 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
2882
2883
  instructions: system,
2883
2884
  input,
2884
2885
  tool_choice: toCodexToolChoice(options.toolChoice, options.tools),
2885
- parallel_tool_calls: !responsesLite,
2886
+ parallel_tool_calls: !liteShape,
2886
2887
  include: ["reasoning.encrypted_content"]
2887
2888
  };
2888
2889
  if (options.tools?.length) {
2889
- body.tools = toCodexTools(options.tools);
2890
+ body.tools = toCodexTools(options.tools, options.strictTools ?? true);
2890
2891
  }
2891
2892
  body.prompt_cache_key = normalizePromptCacheKey(options.promptCacheKey ?? "ezcoder");
2892
2893
  if (options.temperature != null && !options.thinking) {
@@ -2898,7 +2899,7 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
2898
2899
  // `ultra` is a client orchestration preset, not a Codex API effort.
2899
2900
  effort: options.thinking === "ultra" ? "max" : options.thinking ?? (responsesLite ? "low" : "none"),
2900
2901
  summary: "auto",
2901
- ...responsesLite ? { context: "all_turns" } : {}
2902
+ ...liteShape ? { context: "all_turns" } : {}
2902
2903
  };
2903
2904
  if (responsesLite) {
2904
2905
  body.text = { verbosity: "low" };
@@ -2910,10 +2911,8 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
2910
2911
  "OpenAI-Beta": "responses=experimental",
2911
2912
  originator: responsesLite ? "codex_cli_rs" : "ezcoder",
2912
2913
  "User-Agent": responsesLite ? `codex_cli_rs/${CODEX_CLIENT_VERSION}` : `ezcoder (${os.platform()} ${os.release()}; ${os.arch()})`,
2913
- ...responsesLite ? {
2914
- version: CODEX_CLIENT_VERSION,
2915
- "X-OpenAI-Internal-Codex-Responses-Lite": "true"
2916
- } : {}
2914
+ ...responsesLite ? { version: CODEX_CLIENT_VERSION } : {},
2915
+ ...liteShape ? { "X-OpenAI-Internal-Codex-Responses-Lite": "true" } : {}
2917
2916
  };
2918
2917
  if (options.accountId) {
2919
2918
  headers["chatgpt-account-id"] = options.accountId;
@@ -3377,15 +3376,17 @@ function toCodexInput(messages, options) {
3377
3376
  }
3378
3377
  return { system, input };
3379
3378
  }
3380
- function toCodexTools(tools) {
3379
+ function toCodexTools(tools, strictTools) {
3381
3380
  return tools.map((tool) => {
3382
3381
  let parameters = resolveToolSchema(tool);
3383
3382
  let strict = null;
3384
- try {
3385
- parameters = makeStrictToolSchema(parameters);
3386
- strict = true;
3387
- } catch (error) {
3388
- if (!(error instanceof UnsupportedStrictSchemaError)) throw error;
3383
+ if (strictTools) {
3384
+ try {
3385
+ parameters = makeStrictToolSchema(parameters);
3386
+ strict = true;
3387
+ } catch (error) {
3388
+ if (!(error instanceof UnsupportedStrictSchemaError)) throw error;
3389
+ }
3389
3390
  }
3390
3391
  return {
3391
3392
  type: "function",
@@ -3622,6 +3623,17 @@ function stripUnsupportedSchemaFields(value) {
3622
3623
  }
3623
3624
  delete value.$schema;
3624
3625
  delete value.additionalProperties;
3626
+ for (const [key, target, step] of [
3627
+ ["exclusiveMinimum", "minimum", 1],
3628
+ ["exclusiveMaximum", "maximum", -1]
3629
+ ]) {
3630
+ const bound = value[key];
3631
+ if (bound === void 0) continue;
3632
+ delete value[key];
3633
+ if (typeof bound === "number" && value[target] === void 0) {
3634
+ value[target] = value.type === "integer" ? bound + step : bound;
3635
+ }
3636
+ }
3625
3637
  for (const item of Object.values(value)) {
3626
3638
  if (isJsonObject(item) || Array.isArray(item)) {
3627
3639
  stripUnsupportedSchemaFields(item);
@@ -4765,6 +4777,7 @@ export {
4765
4777
  toAnthropicMessages,
4766
4778
  toOpenAIMessages,
4767
4779
  toWellFormedText,
4768
- toolCallNameRuleFor
4780
+ toolCallNameRuleFor,
4781
+ usesResponsesLite
4769
4782
  };
4770
4783
  //# sourceMappingURL=index.js.map