@kenkaiiii/gg-ai 5.79.0 → 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 CHANGED
@@ -38,6 +38,7 @@ __export(index_exports, {
38
38
  TOOL_CALL_NAME_RULES: () => TOOL_CALL_NAME_RULES,
39
39
  clampProviderContextImages: () => clampProviderContextImages,
40
40
  classifyProviderError: () => classifyProviderError,
41
+ continuesTurn: () => continuesTurn,
41
42
  dropInvalidToolCalls: () => dropInvalidToolCalls,
42
43
  embed: () => embed,
43
44
  environmentSecrets: () => environmentSecrets,
@@ -49,6 +50,7 @@ __export(index_exports, {
49
50
  isUsageLimitError: () => isUsageLimitError,
50
51
  isValidToolCallName: () => isValidToolCallName,
51
52
  localWireModelId: () => localWireModelId,
53
+ opensTurn: () => opensTurn,
52
54
  palsuAssistantMessage: () => palsuAssistantMessage,
53
55
  palsuEmbedding: () => palsuEmbedding,
54
56
  palsuRerankScore: () => palsuRerankScore,
@@ -773,6 +775,20 @@ function getReasoningField(key) {
773
775
  return detectedFields.get(key) ?? DEFAULT_REASONING_FIELD;
774
776
  }
775
777
 
778
+ // src/utils/turn-continuation.ts
779
+ var CONTINUES_TURN = /* @__PURE__ */ Symbol("gg.continuesTurn");
780
+ function markContinuesTurn(message) {
781
+ const marked = { ...message };
782
+ marked[CONTINUES_TURN] = true;
783
+ return marked;
784
+ }
785
+ function continuesTurn(message) {
786
+ return message[CONTINUES_TURN] === true;
787
+ }
788
+ function opensTurn(message) {
789
+ return message.role === "user" && !continuesTurn(message);
790
+ }
791
+
776
792
  // src/providers/transform.ts
777
793
  function hasValidThinkingSignature(part) {
778
794
  return typeof part.signature === "string" && part.signature.trim().length > 0;
@@ -1212,7 +1228,7 @@ function toAnthropicMessages(messages, cacheControl, options) {
1212
1228
  const keepFallbackBlocks = options?.fallbackBlocks === true;
1213
1229
  const droppedToolCallIds = /* @__PURE__ */ new Set();
1214
1230
  const trajectoryStartIdx = messages.reduce(
1215
- (last, m, i) => m.role === "user" ? i : last,
1231
+ (last, m, i) => opensTurn(m) ? i : last,
1216
1232
  -1
1217
1233
  );
1218
1234
  let msgIdx = -1;
@@ -1228,7 +1244,7 @@ function toAnthropicMessages(messages, cacheControl, options) {
1228
1244
  } else if (!msg.content.some((p) => !(p.type === "text" && p.text === ""))) {
1229
1245
  continue;
1230
1246
  }
1231
- userTurnIdx.push(out.length);
1247
+ if (opensTurn(msg)) userTurnIdx.push(out.length);
1232
1248
  out.push({
1233
1249
  role: "user",
1234
1250
  content: typeof msg.content === "string" ? msg.content : msg.content.filter((part) => !(part.type === "text" && part.text === "")).map((part) => {
@@ -4990,8 +5006,8 @@ function stripMessageProvenance(messages) {
4990
5006
  const message = messages[index];
4991
5007
  if (!message.provenance) continue;
4992
5008
  stripped ??= messages.slice();
4993
- const { provenance: _provenance, ...wireMessage } = message;
4994
- stripped[index] = wireMessage;
5009
+ const { provenance, ...wireMessage } = message;
5010
+ stripped[index] = provenance.kind === "notification" && message.role === "user" ? markContinuesTurn(wireMessage) : wireMessage;
4995
5011
  }
4996
5012
  return stripped ?? messages;
4997
5013
  }
@@ -5589,6 +5605,7 @@ function palsuRerankScore(query, document) {
5589
5605
  TOOL_CALL_NAME_RULES,
5590
5606
  clampProviderContextImages,
5591
5607
  classifyProviderError,
5608
+ continuesTurn,
5592
5609
  dropInvalidToolCalls,
5593
5610
  embed,
5594
5611
  environmentSecrets,
@@ -5600,6 +5617,7 @@ function palsuRerankScore(query, document) {
5600
5617
  isUsageLimitError,
5601
5618
  isValidToolCallName,
5602
5619
  localWireModelId,
5620
+ opensTurn,
5603
5621
  palsuAssistantMessage,
5604
5622
  palsuEmbedding,
5605
5623
  palsuRerankScore,