@kenkaiiii/gg-ai 5.71.0 → 5.72.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.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, type ErrorEvent, type ErrorSource, EventStream, type FormattedError, GGAIError, 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, type ErrorEvent, type ErrorSource, EventStream, type FormattedError, GGAIError, 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, type ErrorEvent, type ErrorSource, EventStream, type FormattedError, GGAIError, 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, type ErrorEvent, type ErrorSource, EventStream, type FormattedError, GGAIError, 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
@@ -2352,7 +2352,7 @@ async function* runStream2(options) {
2352
2352
  ...options.thinking && !usesThinkingParam && !isKimiK3 && !isKimiK27 && !isLocal ? { reasoning_effort: toOpenAIReasoningEffort(options.thinking, options.model) } : {},
2353
2353
  ...options.tools?.length ? {
2354
2354
  tools: toOpenAITools(options.tools, {
2355
- strict: supportsStrictToolSampling(options.provider)
2355
+ strict: supportsStrictToolSampling(options.provider) && (options.strictTools ?? true)
2356
2356
  })
2357
2357
  } : {},
2358
2358
  ...options.toolChoice && options.tools?.length ? { tool_choice: toOpenAIToolChoice(options.toolChoice) } : {},
@@ -2867,6 +2867,7 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
2867
2867
  const downgraded = downgradeUnsupportedVideos(downgradedImages, options.supportsVideo);
2868
2868
  const { system, input } = toCodexInput(downgraded, { supportsImages: options.supportsImages });
2869
2869
  const responsesLite = usesResponsesLite(options.model);
2870
+ const liteShape = options.responsesLite ?? responsesLite;
2870
2871
  const body = {
2871
2872
  model: options.model,
2872
2873
  store: false,
@@ -2874,11 +2875,11 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
2874
2875
  instructions: system,
2875
2876
  input,
2876
2877
  tool_choice: toCodexToolChoice(options.toolChoice, options.tools),
2877
- parallel_tool_calls: !responsesLite,
2878
+ parallel_tool_calls: !liteShape,
2878
2879
  include: ["reasoning.encrypted_content"]
2879
2880
  };
2880
2881
  if (options.tools?.length) {
2881
- body.tools = toCodexTools(options.tools);
2882
+ body.tools = toCodexTools(options.tools, options.strictTools ?? true);
2882
2883
  }
2883
2884
  body.prompt_cache_key = normalizePromptCacheKey(options.promptCacheKey ?? "ggcoder");
2884
2885
  if (options.temperature != null && !options.thinking) {
@@ -2890,7 +2891,7 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
2890
2891
  // `ultra` is a client orchestration preset, not a Codex API effort.
2891
2892
  effort: options.thinking === "ultra" ? "max" : options.thinking ?? (responsesLite ? "low" : "none"),
2892
2893
  summary: "auto",
2893
- ...responsesLite ? { context: "all_turns" } : {}
2894
+ ...liteShape ? { context: "all_turns" } : {}
2894
2895
  };
2895
2896
  if (responsesLite) {
2896
2897
  body.text = { verbosity: "low" };
@@ -2902,10 +2903,8 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
2902
2903
  "OpenAI-Beta": "responses=experimental",
2903
2904
  originator: responsesLite ? "codex_cli_rs" : "ggcoder",
2904
2905
  "User-Agent": responsesLite ? `codex_cli_rs/${CODEX_CLIENT_VERSION}` : `ggcoder (${os.platform()} ${os.release()}; ${os.arch()})`,
2905
- ...responsesLite ? {
2906
- version: CODEX_CLIENT_VERSION,
2907
- "X-OpenAI-Internal-Codex-Responses-Lite": "true"
2908
- } : {}
2906
+ ...responsesLite ? { version: CODEX_CLIENT_VERSION } : {},
2907
+ ...liteShape ? { "X-OpenAI-Internal-Codex-Responses-Lite": "true" } : {}
2909
2908
  };
2910
2909
  if (options.accountId) {
2911
2910
  headers["chatgpt-account-id"] = options.accountId;
@@ -3369,15 +3368,17 @@ function toCodexInput(messages, options) {
3369
3368
  }
3370
3369
  return { system, input };
3371
3370
  }
3372
- function toCodexTools(tools) {
3371
+ function toCodexTools(tools, strictTools) {
3373
3372
  return tools.map((tool) => {
3374
3373
  let parameters = resolveToolSchema(tool);
3375
3374
  let strict = null;
3376
- try {
3377
- parameters = makeStrictToolSchema(parameters);
3378
- strict = true;
3379
- } catch (error) {
3380
- if (!(error instanceof UnsupportedStrictSchemaError)) throw error;
3375
+ if (strictTools) {
3376
+ try {
3377
+ parameters = makeStrictToolSchema(parameters);
3378
+ strict = true;
3379
+ } catch (error) {
3380
+ if (!(error instanceof UnsupportedStrictSchemaError)) throw error;
3381
+ }
3381
3382
  }
3382
3383
  return {
3383
3384
  type: "function",
@@ -3614,6 +3615,17 @@ function stripUnsupportedSchemaFields(value) {
3614
3615
  }
3615
3616
  delete value.$schema;
3616
3617
  delete value.additionalProperties;
3618
+ for (const [key, target, step] of [
3619
+ ["exclusiveMinimum", "minimum", 1],
3620
+ ["exclusiveMaximum", "maximum", -1]
3621
+ ]) {
3622
+ const bound = value[key];
3623
+ if (bound === void 0) continue;
3624
+ delete value[key];
3625
+ if (typeof bound === "number" && value[target] === void 0) {
3626
+ value[target] = value.type === "integer" ? bound + step : bound;
3627
+ }
3628
+ }
3617
3629
  for (const item of Object.values(value)) {
3618
3630
  if (isJsonObject(item) || Array.isArray(item)) {
3619
3631
  stripUnsupportedSchemaFields(item);
@@ -4751,6 +4763,7 @@ export {
4751
4763
  toAnthropicMessages,
4752
4764
  toOpenAIMessages,
4753
4765
  toWellFormedText,
4754
- toolCallNameRuleFor
4766
+ toolCallNameRuleFor,
4767
+ usesResponsesLite
4755
4768
  };
4756
4769
  //# sourceMappingURL=index.js.map