@kenkaiiii/gg-ai 5.87.3 → 5.88.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
@@ -60,6 +60,13 @@ interface ToolResult {
60
60
  /** Which budget triggered the trim. */
61
61
  scope: "per-result" | "per-turn";
62
62
  };
63
+ /**
64
+ * Deferred tools (names from `StreamOptions.deferredTools`) that became
65
+ * callable while this tool ran. Providers with transcript-anchored tool
66
+ * loading (Anthropic `tool_reference`, OpenAI client `tool_search_output`)
67
+ * load them here instead of growing the cached `tools` block.
68
+ */
69
+ loadedTools?: string[];
63
70
  }
64
71
  interface ServerToolCall {
65
72
  type: "server_tool_call";
@@ -219,6 +226,14 @@ interface StreamOptions {
219
226
  model: string;
220
227
  messages: Message[];
221
228
  tools?: Tool[];
229
+ /**
230
+ * Stable, ordered catalog of on-demand tools (a superset of any of them that
231
+ * are live in `tools`). Providers that support deferred tool loading send
232
+ * the whole catalog from the first request and load a tool through the
233
+ * transcript (see `ToolResult.loadedTools`), so the cached tools block never
234
+ * changes. Others ignore it and send `tools` only.
235
+ */
236
+ deferredTools?: Tool[];
222
237
  toolChoice?: ToolChoice;
223
238
  serverTools?: ServerToolDefinition[];
224
239
  maxTokens?: number;
@@ -685,6 +700,36 @@ declare class ProviderRegistryImpl {
685
700
  /** Global provider registry. Import this to register custom providers. */
686
701
  declare const providerRegistry: ProviderRegistryImpl;
687
702
 
703
+ /**
704
+ * How long a pre-opened origin counts as warm. Matches the pool's idle
705
+ * keep-alive (PROVIDER_KEEP_ALIVE_TIMEOUT_MS): inside this window the socket a
706
+ * previous request or pre-open left is still pooled, so another one is waste.
707
+ */
708
+ declare const PRECONNECT_INTERVAL_MS = 30000;
709
+ /** The https origin a route's connections pool under, or undefined when none is worth opening. */
710
+ declare function preconnectOrigin(options: {
711
+ provider: Provider;
712
+ baseUrl?: string;
713
+ accountId?: string;
714
+ }): string | undefined;
715
+ interface PreconnectOptions {
716
+ provider: Provider;
717
+ baseUrl?: string;
718
+ accountId?: string;
719
+ /** Last pre-open per origin (ms). Callers own it, so state is never module-global. */
720
+ warmedAt: Map<string, number>;
721
+ now?: number;
722
+ fetch?: typeof globalThis.fetch;
723
+ }
724
+ /**
725
+ * Open the DNS+TCP+TLS connection to the provider's origin ahead of the first
726
+ * real request, through the same keep-alive pool those requests use. Sends a
727
+ * bodiless, unauthenticated `HEAD <baseUrl>` — no credentials, no tokens, no side
728
+ * effects — and drops whatever comes back. Fire-and-forget: never throws.
729
+ * Returns the origin it opened, or undefined when it skipped.
730
+ */
731
+ declare function preconnectProvider(options: PreconnectOptions): string | undefined;
732
+
688
733
  /**
689
734
  * Error model for gg-ai and downstream consumers.
690
735
  *
@@ -976,6 +1021,9 @@ declare function toAnthropicMessages(messages: Message[], cacheControl?: {
976
1021
  * request carries the server-side-fallback beta; otherwise they are
977
1022
  * stripped (after applying the replay rules). Default false. */
978
1023
  fallbackBlocks?: boolean;
1024
+ /** Deferred tools to load in place: a tool result that names one in
1025
+ * `loadedTools` carries `tool_reference` blocks (see planDeferredTools). */
1026
+ toolReferences?: ReadonlySet<string>;
979
1027
  }): {
980
1028
  system: Anthropic.TextBlockParam[] | undefined;
981
1029
  messages: Anthropic.MessageParam[];
@@ -1117,4 +1165,4 @@ declare function palsuEmbedding(text: string, dimensions?: number): number[];
1117
1165
  /** Deterministic fake relevance: the share of distinct query words found in the document (0–1). */
1118
1166
  declare function palsuRerankScore(query: string, document: string): number;
1119
1167
 
1120
- export { type AssistantMessage, CLAUDE_CODE_FALLBACK_VERSION, CODEX_CLIENT_VERSION, type CacheRetention, type ChatErrorReason, type ContentPart, type DoneEvent, type EmbedInputType, type EmbedOptions, type EmbedResult, type EmbedUsage, type ErrorEvent, type ErrorSource, EventStream, FAST_MODE_SUFFIX, type FastModeRejection, type FastModeResolution, type FormattedChatError, type FormattedError, GGAIError, type ImageContent, type Message, type MessageProvenance, type MessageProvenanceKind, type MessageProvenanceSource, type MessageProvenanceVisibility, type OpenRouterProviderPreferences, type PalsuModelConfig, type PalsuModelHandle, type PalsuProviderConfig, type PalsuProviderHandle, type PalsuProviderState, type PalsuResponse, type PalsuResponseFactory, type PreparedContext, type Provider, type ProviderCapability, type ProviderDiagnosticFn, type ProviderEmbedFn, type ProviderEmbedRequest, type ProviderEmbedResponse, type ProviderEntry, ProviderError, type ProviderOptions, type ProviderRerankFn, type ProviderRerankRequest, type ProviderRerankResponse, type ProviderStreamFn, REDACTED as REDACTION_MARKER, type RawContent, type RedactionOptions, type RerankOptions, type RerankResponse, type RerankResult, type RerankUsage, ResponseStalledError, 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, continuesTurn, describeFastModeRejection, dropInvalidToolCalls, embed, environmentSecrets, formatChatError, formatError, formatErrorForDisplay, getClaudeCliUserAgent, getClaudeCodeVersion, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, isValidToolCallName, localWireModelId, opensTurn, palsuAssistantMessage, palsuEmbedding, palsuRerankScore, palsuText, palsuThinking, palsuToolCall, parseFastModeRejection, pendingClaudeCodeVersionRefresh, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, rerank, resolveFastModeModel, resolveToolSchema, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText, toolCallNameRuleFor, usesResponsesLite };
1168
+ export { type AssistantMessage, CLAUDE_CODE_FALLBACK_VERSION, CODEX_CLIENT_VERSION, type CacheRetention, type ChatErrorReason, type ContentPart, type DoneEvent, type EmbedInputType, type EmbedOptions, type EmbedResult, type EmbedUsage, type ErrorEvent, type ErrorSource, EventStream, FAST_MODE_SUFFIX, type FastModeRejection, type FastModeResolution, type FormattedChatError, type FormattedError, GGAIError, type ImageContent, type Message, type MessageProvenance, type MessageProvenanceKind, type MessageProvenanceSource, type MessageProvenanceVisibility, type OpenRouterProviderPreferences, PRECONNECT_INTERVAL_MS, type PalsuModelConfig, type PalsuModelHandle, type PalsuProviderConfig, type PalsuProviderHandle, type PalsuProviderState, type PalsuResponse, type PalsuResponseFactory, type PreconnectOptions, type PreparedContext, type Provider, type ProviderCapability, type ProviderDiagnosticFn, type ProviderEmbedFn, type ProviderEmbedRequest, type ProviderEmbedResponse, type ProviderEntry, ProviderError, type ProviderOptions, type ProviderRerankFn, type ProviderRerankRequest, type ProviderRerankResponse, type ProviderStreamFn, REDACTED as REDACTION_MARKER, type RawContent, type RedactionOptions, type RerankOptions, type RerankResponse, type RerankResult, type RerankUsage, ResponseStalledError, 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, continuesTurn, describeFastModeRejection, dropInvalidToolCalls, embed, environmentSecrets, formatChatError, formatError, formatErrorForDisplay, getClaudeCliUserAgent, getClaudeCodeVersion, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, isValidToolCallName, localWireModelId, opensTurn, palsuAssistantMessage, palsuEmbedding, palsuRerankScore, palsuText, palsuThinking, palsuToolCall, parseFastModeRejection, pendingClaudeCodeVersionRefresh, preconnectOrigin, preconnectProvider, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, rerank, resolveFastModeModel, resolveToolSchema, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText, toolCallNameRuleFor, usesResponsesLite };
package/dist/index.d.ts CHANGED
@@ -60,6 +60,13 @@ interface ToolResult {
60
60
  /** Which budget triggered the trim. */
61
61
  scope: "per-result" | "per-turn";
62
62
  };
63
+ /**
64
+ * Deferred tools (names from `StreamOptions.deferredTools`) that became
65
+ * callable while this tool ran. Providers with transcript-anchored tool
66
+ * loading (Anthropic `tool_reference`, OpenAI client `tool_search_output`)
67
+ * load them here instead of growing the cached `tools` block.
68
+ */
69
+ loadedTools?: string[];
63
70
  }
64
71
  interface ServerToolCall {
65
72
  type: "server_tool_call";
@@ -219,6 +226,14 @@ interface StreamOptions {
219
226
  model: string;
220
227
  messages: Message[];
221
228
  tools?: Tool[];
229
+ /**
230
+ * Stable, ordered catalog of on-demand tools (a superset of any of them that
231
+ * are live in `tools`). Providers that support deferred tool loading send
232
+ * the whole catalog from the first request and load a tool through the
233
+ * transcript (see `ToolResult.loadedTools`), so the cached tools block never
234
+ * changes. Others ignore it and send `tools` only.
235
+ */
236
+ deferredTools?: Tool[];
222
237
  toolChoice?: ToolChoice;
223
238
  serverTools?: ServerToolDefinition[];
224
239
  maxTokens?: number;
@@ -685,6 +700,36 @@ declare class ProviderRegistryImpl {
685
700
  /** Global provider registry. Import this to register custom providers. */
686
701
  declare const providerRegistry: ProviderRegistryImpl;
687
702
 
703
+ /**
704
+ * How long a pre-opened origin counts as warm. Matches the pool's idle
705
+ * keep-alive (PROVIDER_KEEP_ALIVE_TIMEOUT_MS): inside this window the socket a
706
+ * previous request or pre-open left is still pooled, so another one is waste.
707
+ */
708
+ declare const PRECONNECT_INTERVAL_MS = 30000;
709
+ /** The https origin a route's connections pool under, or undefined when none is worth opening. */
710
+ declare function preconnectOrigin(options: {
711
+ provider: Provider;
712
+ baseUrl?: string;
713
+ accountId?: string;
714
+ }): string | undefined;
715
+ interface PreconnectOptions {
716
+ provider: Provider;
717
+ baseUrl?: string;
718
+ accountId?: string;
719
+ /** Last pre-open per origin (ms). Callers own it, so state is never module-global. */
720
+ warmedAt: Map<string, number>;
721
+ now?: number;
722
+ fetch?: typeof globalThis.fetch;
723
+ }
724
+ /**
725
+ * Open the DNS+TCP+TLS connection to the provider's origin ahead of the first
726
+ * real request, through the same keep-alive pool those requests use. Sends a
727
+ * bodiless, unauthenticated `HEAD <baseUrl>` — no credentials, no tokens, no side
728
+ * effects — and drops whatever comes back. Fire-and-forget: never throws.
729
+ * Returns the origin it opened, or undefined when it skipped.
730
+ */
731
+ declare function preconnectProvider(options: PreconnectOptions): string | undefined;
732
+
688
733
  /**
689
734
  * Error model for gg-ai and downstream consumers.
690
735
  *
@@ -976,6 +1021,9 @@ declare function toAnthropicMessages(messages: Message[], cacheControl?: {
976
1021
  * request carries the server-side-fallback beta; otherwise they are
977
1022
  * stripped (after applying the replay rules). Default false. */
978
1023
  fallbackBlocks?: boolean;
1024
+ /** Deferred tools to load in place: a tool result that names one in
1025
+ * `loadedTools` carries `tool_reference` blocks (see planDeferredTools). */
1026
+ toolReferences?: ReadonlySet<string>;
979
1027
  }): {
980
1028
  system: Anthropic.TextBlockParam[] | undefined;
981
1029
  messages: Anthropic.MessageParam[];
@@ -1117,4 +1165,4 @@ declare function palsuEmbedding(text: string, dimensions?: number): number[];
1117
1165
  /** Deterministic fake relevance: the share of distinct query words found in the document (0–1). */
1118
1166
  declare function palsuRerankScore(query: string, document: string): number;
1119
1167
 
1120
- export { type AssistantMessage, CLAUDE_CODE_FALLBACK_VERSION, CODEX_CLIENT_VERSION, type CacheRetention, type ChatErrorReason, type ContentPart, type DoneEvent, type EmbedInputType, type EmbedOptions, type EmbedResult, type EmbedUsage, type ErrorEvent, type ErrorSource, EventStream, FAST_MODE_SUFFIX, type FastModeRejection, type FastModeResolution, type FormattedChatError, type FormattedError, GGAIError, type ImageContent, type Message, type MessageProvenance, type MessageProvenanceKind, type MessageProvenanceSource, type MessageProvenanceVisibility, type OpenRouterProviderPreferences, type PalsuModelConfig, type PalsuModelHandle, type PalsuProviderConfig, type PalsuProviderHandle, type PalsuProviderState, type PalsuResponse, type PalsuResponseFactory, type PreparedContext, type Provider, type ProviderCapability, type ProviderDiagnosticFn, type ProviderEmbedFn, type ProviderEmbedRequest, type ProviderEmbedResponse, type ProviderEntry, ProviderError, type ProviderOptions, type ProviderRerankFn, type ProviderRerankRequest, type ProviderRerankResponse, type ProviderStreamFn, REDACTED as REDACTION_MARKER, type RawContent, type RedactionOptions, type RerankOptions, type RerankResponse, type RerankResult, type RerankUsage, ResponseStalledError, 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, continuesTurn, describeFastModeRejection, dropInvalidToolCalls, embed, environmentSecrets, formatChatError, formatError, formatErrorForDisplay, getClaudeCliUserAgent, getClaudeCodeVersion, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, isValidToolCallName, localWireModelId, opensTurn, palsuAssistantMessage, palsuEmbedding, palsuRerankScore, palsuText, palsuThinking, palsuToolCall, parseFastModeRejection, pendingClaudeCodeVersionRefresh, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, rerank, resolveFastModeModel, resolveToolSchema, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText, toolCallNameRuleFor, usesResponsesLite };
1168
+ export { type AssistantMessage, CLAUDE_CODE_FALLBACK_VERSION, CODEX_CLIENT_VERSION, type CacheRetention, type ChatErrorReason, type ContentPart, type DoneEvent, type EmbedInputType, type EmbedOptions, type EmbedResult, type EmbedUsage, type ErrorEvent, type ErrorSource, EventStream, FAST_MODE_SUFFIX, type FastModeRejection, type FastModeResolution, type FormattedChatError, type FormattedError, GGAIError, type ImageContent, type Message, type MessageProvenance, type MessageProvenanceKind, type MessageProvenanceSource, type MessageProvenanceVisibility, type OpenRouterProviderPreferences, PRECONNECT_INTERVAL_MS, type PalsuModelConfig, type PalsuModelHandle, type PalsuProviderConfig, type PalsuProviderHandle, type PalsuProviderState, type PalsuResponse, type PalsuResponseFactory, type PreconnectOptions, type PreparedContext, type Provider, type ProviderCapability, type ProviderDiagnosticFn, type ProviderEmbedFn, type ProviderEmbedRequest, type ProviderEmbedResponse, type ProviderEntry, ProviderError, type ProviderOptions, type ProviderRerankFn, type ProviderRerankRequest, type ProviderRerankResponse, type ProviderStreamFn, REDACTED as REDACTION_MARKER, type RawContent, type RedactionOptions, type RerankOptions, type RerankResponse, type RerankResult, type RerankUsage, ResponseStalledError, 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, continuesTurn, describeFastModeRejection, dropInvalidToolCalls, embed, environmentSecrets, formatChatError, formatError, formatErrorForDisplay, getClaudeCliUserAgent, getClaudeCodeVersion, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, isValidToolCallName, localWireModelId, opensTurn, palsuAssistantMessage, palsuEmbedding, palsuRerankScore, palsuText, palsuThinking, palsuToolCall, parseFastModeRejection, pendingClaudeCodeVersionRefresh, preconnectOrigin, preconnectProvider, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, rerank, resolveFastModeModel, resolveToolSchema, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText, toolCallNameRuleFor, usesResponsesLite };