@kenkaiiii/gg-ai 5.44.2 → 5.44.3
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 +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -1
- package/dist/index.d.ts +42 -1
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -530,6 +530,47 @@ type ProviderDiagnosticFn = (phase: string, data?: Record<string, unknown>) => v
|
|
|
530
530
|
/** Register a diagnostic callback for provider-level tracing. */
|
|
531
531
|
declare function setProviderDiagnostic(fn: ProviderDiagnosticFn | null): void;
|
|
532
532
|
|
|
533
|
+
/**
|
|
534
|
+
* Converts a Zod schema to a JSON Schema object suitable for provider tool
|
|
535
|
+
* parameter definitions.
|
|
536
|
+
*
|
|
537
|
+
* Anthropic's `input_schema` validator is strict in two ways:
|
|
538
|
+
*
|
|
539
|
+
* 1. The root must be `type: "object"`. Returns 400 with
|
|
540
|
+
* `tools.N.custom.input_schema.type: Field required` otherwise.
|
|
541
|
+
*
|
|
542
|
+
* 2. The root must NOT contain `oneOf`, `anyOf`, or `allOf`. Returns 400 with
|
|
543
|
+
* `input_schema does not support oneOf, allOf, or anyOf at the top level`.
|
|
544
|
+
*
|
|
545
|
+
* Both rules trip whenever a tool's parameters are defined via
|
|
546
|
+
* `z.discriminatedUnion(...)` or `z.union(...)` — Zod 4's
|
|
547
|
+
* `z.toJSONSchema` emits `{oneOf: [...]}` at the root with no `type`.
|
|
548
|
+
*
|
|
549
|
+
* The fix is to collapse the union into a single flat object schema:
|
|
550
|
+
*
|
|
551
|
+
* - properties = union of all branch properties (later branches win on
|
|
552
|
+
* conflict; that's fine because the model only uses these for hints —
|
|
553
|
+
* Zod's actual `tool.parameters.parse(args)` is the real validator)
|
|
554
|
+
* - required = intersection of branch `required` arrays (a field is only
|
|
555
|
+
* required if EVERY branch requires it)
|
|
556
|
+
* - if the union has a discriminator field (every branch has the same
|
|
557
|
+
* property as a `const`), we replace the discriminator's per-branch
|
|
558
|
+
* `const` with an `enum` listing every literal — the model gets a clear
|
|
559
|
+
* hint of the valid action values without needing oneOf
|
|
560
|
+
*
|
|
561
|
+
* The flattening is lossy for *schema-level* constraints (e.g. "if action=X,
|
|
562
|
+
* then field Y is required") — Zod still enforces those at parse time. For
|
|
563
|
+
* the model's purposes this is identical to a single object with optional
|
|
564
|
+
* fields and a discriminator enum, which is exactly how Anthropic-supported
|
|
565
|
+
* tools are typically authored anyway.
|
|
566
|
+
*/
|
|
567
|
+
type JsonSchema = Record<string, unknown>;
|
|
568
|
+
/**
|
|
569
|
+
* Resolve a tool's JSON Schema for provider tool definitions: prefer the
|
|
570
|
+
* tool's pre-built `rawInputSchema`, otherwise convert its Zod `parameters`.
|
|
571
|
+
*/
|
|
572
|
+
declare function resolveToolSchema(tool: Tool): JsonSchema;
|
|
573
|
+
|
|
533
574
|
/**
|
|
534
575
|
* Cap historical images before provider dispatch, removing the oldest first.
|
|
535
576
|
* The persisted/live conversation is never mutated; only modified messages and
|
|
@@ -642,4 +683,4 @@ interface PalsuProviderConfig {
|
|
|
642
683
|
*/
|
|
643
684
|
declare function registerPalsuProvider(config?: PalsuProviderConfig): PalsuProviderHandle;
|
|
644
685
|
|
|
645
|
-
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 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, type TextContent, type TextDeltaEvent, type ThinkingContent, type ThinkingDeltaEvent, type ThinkingLevel, type Tool, type ToolCall, type ToolCallDeltaEvent, type ToolCallDoneEvent, type ToolChoice, type ToolResult, type ToolResultContent, type ToolResultMessage, type Usage, type UserMessage, type VideoContent, clampProviderContextImages, classifyProviderError, environmentSecrets, formatError, formatErrorForDisplay, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, localWireModelId, palsuAssistantMessage, palsuText, palsuThinking, palsuToolCall, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText };
|
|
686
|
+
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 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, type TextContent, type TextDeltaEvent, type ThinkingContent, type ThinkingDeltaEvent, type ThinkingLevel, type Tool, type ToolCall, type ToolCallDeltaEvent, type ToolCallDoneEvent, type ToolChoice, type ToolResult, type ToolResultContent, type ToolResultMessage, type Usage, type UserMessage, type VideoContent, clampProviderContextImages, classifyProviderError, environmentSecrets, formatError, formatErrorForDisplay, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, localWireModelId, palsuAssistantMessage, palsuText, palsuThinking, palsuToolCall, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, resolveToolSchema, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText };
|
package/dist/index.d.ts
CHANGED
|
@@ -530,6 +530,47 @@ type ProviderDiagnosticFn = (phase: string, data?: Record<string, unknown>) => v
|
|
|
530
530
|
/** Register a diagnostic callback for provider-level tracing. */
|
|
531
531
|
declare function setProviderDiagnostic(fn: ProviderDiagnosticFn | null): void;
|
|
532
532
|
|
|
533
|
+
/**
|
|
534
|
+
* Converts a Zod schema to a JSON Schema object suitable for provider tool
|
|
535
|
+
* parameter definitions.
|
|
536
|
+
*
|
|
537
|
+
* Anthropic's `input_schema` validator is strict in two ways:
|
|
538
|
+
*
|
|
539
|
+
* 1. The root must be `type: "object"`. Returns 400 with
|
|
540
|
+
* `tools.N.custom.input_schema.type: Field required` otherwise.
|
|
541
|
+
*
|
|
542
|
+
* 2. The root must NOT contain `oneOf`, `anyOf`, or `allOf`. Returns 400 with
|
|
543
|
+
* `input_schema does not support oneOf, allOf, or anyOf at the top level`.
|
|
544
|
+
*
|
|
545
|
+
* Both rules trip whenever a tool's parameters are defined via
|
|
546
|
+
* `z.discriminatedUnion(...)` or `z.union(...)` — Zod 4's
|
|
547
|
+
* `z.toJSONSchema` emits `{oneOf: [...]}` at the root with no `type`.
|
|
548
|
+
*
|
|
549
|
+
* The fix is to collapse the union into a single flat object schema:
|
|
550
|
+
*
|
|
551
|
+
* - properties = union of all branch properties (later branches win on
|
|
552
|
+
* conflict; that's fine because the model only uses these for hints —
|
|
553
|
+
* Zod's actual `tool.parameters.parse(args)` is the real validator)
|
|
554
|
+
* - required = intersection of branch `required` arrays (a field is only
|
|
555
|
+
* required if EVERY branch requires it)
|
|
556
|
+
* - if the union has a discriminator field (every branch has the same
|
|
557
|
+
* property as a `const`), we replace the discriminator's per-branch
|
|
558
|
+
* `const` with an `enum` listing every literal — the model gets a clear
|
|
559
|
+
* hint of the valid action values without needing oneOf
|
|
560
|
+
*
|
|
561
|
+
* The flattening is lossy for *schema-level* constraints (e.g. "if action=X,
|
|
562
|
+
* then field Y is required") — Zod still enforces those at parse time. For
|
|
563
|
+
* the model's purposes this is identical to a single object with optional
|
|
564
|
+
* fields and a discriminator enum, which is exactly how Anthropic-supported
|
|
565
|
+
* tools are typically authored anyway.
|
|
566
|
+
*/
|
|
567
|
+
type JsonSchema = Record<string, unknown>;
|
|
568
|
+
/**
|
|
569
|
+
* Resolve a tool's JSON Schema for provider tool definitions: prefer the
|
|
570
|
+
* tool's pre-built `rawInputSchema`, otherwise convert its Zod `parameters`.
|
|
571
|
+
*/
|
|
572
|
+
declare function resolveToolSchema(tool: Tool): JsonSchema;
|
|
573
|
+
|
|
533
574
|
/**
|
|
534
575
|
* Cap historical images before provider dispatch, removing the oldest first.
|
|
535
576
|
* The persisted/live conversation is never mutated; only modified messages and
|
|
@@ -642,4 +683,4 @@ interface PalsuProviderConfig {
|
|
|
642
683
|
*/
|
|
643
684
|
declare function registerPalsuProvider(config?: PalsuProviderConfig): PalsuProviderHandle;
|
|
644
685
|
|
|
645
|
-
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 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, type TextContent, type TextDeltaEvent, type ThinkingContent, type ThinkingDeltaEvent, type ThinkingLevel, type Tool, type ToolCall, type ToolCallDeltaEvent, type ToolCallDoneEvent, type ToolChoice, type ToolResult, type ToolResultContent, type ToolResultMessage, type Usage, type UserMessage, type VideoContent, clampProviderContextImages, classifyProviderError, environmentSecrets, formatError, formatErrorForDisplay, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, localWireModelId, palsuAssistantMessage, palsuText, palsuThinking, palsuToolCall, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText };
|
|
686
|
+
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 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, type TextContent, type TextDeltaEvent, type ThinkingContent, type ThinkingDeltaEvent, type ThinkingLevel, type Tool, type ToolCall, type ToolCallDeltaEvent, type ToolCallDoneEvent, type ToolChoice, type ToolResult, type ToolResultContent, type ToolResultMessage, type Usage, type UserMessage, type VideoContent, clampProviderContextImages, classifyProviderError, environmentSecrets, formatError, formatErrorForDisplay, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, localWireModelId, palsuAssistantMessage, palsuText, palsuThinking, palsuToolCall, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, resolveToolSchema, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText };
|
package/dist/index.js
CHANGED