@kenkaiiii/gg-ai 5.79.1 → 5.79.2
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 +22 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -916,6 +916,11 @@ declare function toOpenAIMessages(messages: Message[], options?: {
|
|
|
916
916
|
reasoningField?: string;
|
|
917
917
|
}): OpenAI.ChatCompletionMessageParam[];
|
|
918
918
|
|
|
919
|
+
/** True for a user-role message that continues the current turn (see above). */
|
|
920
|
+
declare function continuesTurn(message: Message): boolean;
|
|
921
|
+
/** A real turn boundary: a user message that isn't a runtime notice. */
|
|
922
|
+
declare function opensTurn(message: Message): boolean;
|
|
923
|
+
|
|
919
924
|
declare function usesResponsesLite(model: string): boolean;
|
|
920
925
|
|
|
921
926
|
/**
|
|
@@ -1026,4 +1031,4 @@ declare function palsuEmbedding(text: string, dimensions?: number): number[];
|
|
|
1026
1031
|
/** Deterministic fake relevance: the share of distinct query words found in the document (0–1). */
|
|
1027
1032
|
declare function palsuRerankScore(query: string, document: string): number;
|
|
1028
1033
|
|
|
1029
|
-
export { type AssistantMessage, type CacheRetention, type ChatErrorReason, type ContentPart, type DoneEvent, type EmbedInputType, type EmbedOptions, type EmbedResult, type EmbedUsage, type ErrorEvent, type ErrorSource, EventStream, 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, 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, embed, environmentSecrets, formatChatError, formatError, formatErrorForDisplay, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, isValidToolCallName, localWireModelId, palsuAssistantMessage, palsuEmbedding, palsuRerankScore, palsuText, palsuThinking, palsuToolCall, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, rerank, resolveToolSchema, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText, toolCallNameRuleFor, usesResponsesLite };
|
|
1034
|
+
export { type AssistantMessage, type CacheRetention, type ChatErrorReason, type ContentPart, type DoneEvent, type EmbedInputType, type EmbedOptions, type EmbedResult, type EmbedUsage, type ErrorEvent, type ErrorSource, EventStream, 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, 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, dropInvalidToolCalls, embed, environmentSecrets, formatChatError, formatError, formatErrorForDisplay, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, isValidToolCallName, localWireModelId, opensTurn, palsuAssistantMessage, palsuEmbedding, palsuRerankScore, palsuText, palsuThinking, palsuToolCall, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, rerank, resolveToolSchema, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText, toolCallNameRuleFor, usesResponsesLite };
|
package/dist/index.d.ts
CHANGED
|
@@ -916,6 +916,11 @@ declare function toOpenAIMessages(messages: Message[], options?: {
|
|
|
916
916
|
reasoningField?: string;
|
|
917
917
|
}): OpenAI.ChatCompletionMessageParam[];
|
|
918
918
|
|
|
919
|
+
/** True for a user-role message that continues the current turn (see above). */
|
|
920
|
+
declare function continuesTurn(message: Message): boolean;
|
|
921
|
+
/** A real turn boundary: a user message that isn't a runtime notice. */
|
|
922
|
+
declare function opensTurn(message: Message): boolean;
|
|
923
|
+
|
|
919
924
|
declare function usesResponsesLite(model: string): boolean;
|
|
920
925
|
|
|
921
926
|
/**
|
|
@@ -1026,4 +1031,4 @@ declare function palsuEmbedding(text: string, dimensions?: number): number[];
|
|
|
1026
1031
|
/** Deterministic fake relevance: the share of distinct query words found in the document (0–1). */
|
|
1027
1032
|
declare function palsuRerankScore(query: string, document: string): number;
|
|
1028
1033
|
|
|
1029
|
-
export { type AssistantMessage, type CacheRetention, type ChatErrorReason, type ContentPart, type DoneEvent, type EmbedInputType, type EmbedOptions, type EmbedResult, type EmbedUsage, type ErrorEvent, type ErrorSource, EventStream, 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, 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, embed, environmentSecrets, formatChatError, formatError, formatErrorForDisplay, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, isValidToolCallName, localWireModelId, palsuAssistantMessage, palsuEmbedding, palsuRerankScore, palsuText, palsuThinking, palsuToolCall, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, rerank, resolveToolSchema, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText, toolCallNameRuleFor, usesResponsesLite };
|
|
1034
|
+
export { type AssistantMessage, type CacheRetention, type ChatErrorReason, type ContentPart, type DoneEvent, type EmbedInputType, type EmbedOptions, type EmbedResult, type EmbedUsage, type ErrorEvent, type ErrorSource, EventStream, 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, 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, dropInvalidToolCalls, embed, environmentSecrets, formatChatError, formatError, formatErrorForDisplay, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, isValidToolCallName, localWireModelId, opensTurn, palsuAssistantMessage, palsuEmbedding, palsuRerankScore, palsuText, palsuThinking, palsuToolCall, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, rerank, resolveToolSchema, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText, toolCallNameRuleFor, usesResponsesLite };
|
package/dist/index.js
CHANGED
|
@@ -696,6 +696,20 @@ function getReasoningField(key) {
|
|
|
696
696
|
return detectedFields.get(key) ?? DEFAULT_REASONING_FIELD;
|
|
697
697
|
}
|
|
698
698
|
|
|
699
|
+
// src/utils/turn-continuation.ts
|
|
700
|
+
var CONTINUES_TURN = /* @__PURE__ */ Symbol("gg.continuesTurn");
|
|
701
|
+
function markContinuesTurn(message) {
|
|
702
|
+
const marked = { ...message };
|
|
703
|
+
marked[CONTINUES_TURN] = true;
|
|
704
|
+
return marked;
|
|
705
|
+
}
|
|
706
|
+
function continuesTurn(message) {
|
|
707
|
+
return message[CONTINUES_TURN] === true;
|
|
708
|
+
}
|
|
709
|
+
function opensTurn(message) {
|
|
710
|
+
return message.role === "user" && !continuesTurn(message);
|
|
711
|
+
}
|
|
712
|
+
|
|
699
713
|
// src/providers/transform.ts
|
|
700
714
|
function hasValidThinkingSignature(part) {
|
|
701
715
|
return typeof part.signature === "string" && part.signature.trim().length > 0;
|
|
@@ -1135,7 +1149,7 @@ function toAnthropicMessages(messages, cacheControl, options) {
|
|
|
1135
1149
|
const keepFallbackBlocks = options?.fallbackBlocks === true;
|
|
1136
1150
|
const droppedToolCallIds = /* @__PURE__ */ new Set();
|
|
1137
1151
|
const trajectoryStartIdx = messages.reduce(
|
|
1138
|
-
(last, m, i) => m
|
|
1152
|
+
(last, m, i) => opensTurn(m) ? i : last,
|
|
1139
1153
|
-1
|
|
1140
1154
|
);
|
|
1141
1155
|
let msgIdx = -1;
|
|
@@ -1151,7 +1165,7 @@ function toAnthropicMessages(messages, cacheControl, options) {
|
|
|
1151
1165
|
} else if (!msg.content.some((p) => !(p.type === "text" && p.text === ""))) {
|
|
1152
1166
|
continue;
|
|
1153
1167
|
}
|
|
1154
|
-
userTurnIdx.push(out.length);
|
|
1168
|
+
if (opensTurn(msg)) userTurnIdx.push(out.length);
|
|
1155
1169
|
out.push({
|
|
1156
1170
|
role: "user",
|
|
1157
1171
|
content: typeof msg.content === "string" ? msg.content : msg.content.filter((part) => !(part.type === "text" && part.text === "")).map((part) => {
|
|
@@ -4913,8 +4927,8 @@ function stripMessageProvenance(messages) {
|
|
|
4913
4927
|
const message = messages[index];
|
|
4914
4928
|
if (!message.provenance) continue;
|
|
4915
4929
|
stripped ??= messages.slice();
|
|
4916
|
-
const { provenance
|
|
4917
|
-
stripped[index] = wireMessage;
|
|
4930
|
+
const { provenance, ...wireMessage } = message;
|
|
4931
|
+
stripped[index] = provenance.kind === "notification" && message.role === "user" ? markContinuesTurn(wireMessage) : wireMessage;
|
|
4918
4932
|
}
|
|
4919
4933
|
return stripped ?? messages;
|
|
4920
4934
|
}
|
|
@@ -5511,6 +5525,7 @@ export {
|
|
|
5511
5525
|
TOOL_CALL_NAME_RULES,
|
|
5512
5526
|
clampProviderContextImages,
|
|
5513
5527
|
classifyProviderError,
|
|
5528
|
+
continuesTurn,
|
|
5514
5529
|
dropInvalidToolCalls,
|
|
5515
5530
|
embed,
|
|
5516
5531
|
environmentSecrets,
|
|
@@ -5522,6 +5537,7 @@ export {
|
|
|
5522
5537
|
isUsageLimitError,
|
|
5523
5538
|
isValidToolCallName,
|
|
5524
5539
|
localWireModelId,
|
|
5540
|
+
opensTurn,
|
|
5525
5541
|
palsuAssistantMessage,
|
|
5526
5542
|
palsuEmbedding,
|
|
5527
5543
|
palsuRerankScore,
|