jeopi-ai 16.6.21 → 16.6.24

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/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [16.6.23] - 2026-11-13
6
+
7
+ ### Fixed
8
+
9
+ - Updated replay regression coverage to enforce private-reasoning omission on official Anthropic endpoints while preserving signed thinking, visible replies, and paired tool results.
10
+
11
+ ## [16.6.22] - 2026-11-13
12
+
13
+ ### Fixed
14
+
15
+ - Prevented unsigned and cross-provider private thinking from being replayed as plain text to official Anthropic endpoints, including Opus 5.5 and Sonnet 5.5; valid native signed thinking and compatible third-party reasoning replay remain supported.
16
+
17
+ ### Improved
18
+
19
+ - Avoid copying unchanged assistant messages and content arrays during conversation replay, reducing retained output memory and native replay conversion time without changing thinking or tool-result handling.
20
+
5
21
  ## [16.6.19] - 2026-11-10
6
22
 
7
23
  ### Fixed
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "jeopi-ai",
4
- "version": "16.6.21",
4
+ "version": "16.6.24",
5
5
  "description": "Unified LLM API with automatic model discovery and provider configuration",
6
6
  "homepage": "https://github.com/akillness/jeopi",
7
7
  "author": "Can Boluk",
@@ -38,9 +38,9 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@bufbuild/protobuf": "^2.12.0",
41
- "jeopi-catalog": "16.6.21",
42
- "jeopi-utils": "16.6.21",
43
- "jeopi-wire": "16.6.21",
41
+ "jeopi-catalog": "16.6.24",
42
+ "jeopi-utils": "16.6.24",
43
+ "jeopi-wire": "16.6.24",
44
44
  "arktype": "2.2.3",
45
45
  "zod": "^4"
46
46
  },
@@ -3385,6 +3385,9 @@ export function convertAnthropicMessages(
3385
3385
  text: block.text.toWellFormed(),
3386
3386
  });
3387
3387
  } else if (block.type === "thinking") {
3388
+ // Official Anthropic accepts native signed reasoning, not private
3389
+ // reasoning recast as ordinary response text.
3390
+ if (model.compat.officialEndpoint && !block.thinkingSignature?.trim()) continue;
3388
3391
  if (hasSignedThinking) {
3389
3392
  if (!block.thinkingSignature || block.thinkingSignature.trim().length === 0) {
3390
3393
  if (block.thinking.trim().length === 0) continue;
@@ -397,11 +397,14 @@ export function transformMessages<TApi extends Api>(
397
397
  assistantMsg.content.some(b => b.type === "toolCall");
398
398
  const lastBlockIndex = assistantMsg.content.length - 1;
399
399
 
400
- const transformedContent = assistantMsg.content.flatMap((block, blockIndex) => {
400
+ const transformBlock = (
401
+ block: AssistantMessage["content"][number],
402
+ blockIndex: number,
403
+ ): AssistantMessage["content"][number] | [] => {
401
404
  if (block.type === "thinking") {
402
405
  // Only an aborted/errored turn's final (mid-stream) block can hold a
403
- // partial signature; abandoned tool-use turns strip all. Drop the
404
- // untrustworthy signature so the encoder can downgrade the block to text.
406
+ // partial signature; abandoned tool-use turns strip all. The encoder
407
+ // applies the target's unsigned-reasoning policy afterward.
405
408
  const signatureUntrustworthy = abandonedToolUse || (invalidStopReason && blockIndex === lastBlockIndex);
406
409
  let sanitized: typeof block =
407
410
  signatureUntrustworthy && block.thinkingSignature
@@ -414,8 +417,8 @@ export function transformMessages<TApi extends Api>(
414
417
  // Cross-model prior turns crossing an official Anthropic endpoint
415
418
  // must strip the source signature so the downstream encoder
416
419
  // applies its `replayUnsignedThinking` policy (unsigned thinking
417
- // is emitted natively on Anthropic-compatible reasoning endpoints
418
- // and demoted to text on official Anthropic). 3p ↔ 3p replays
420
+ // is emitted natively on compatible reasoning endpoints and dropped
421
+ // on official Anthropic). 3p ↔ 3p replays
419
422
  // keep the signature so the reasoning chain stays signed on
420
423
  // continuation (#2265).
421
424
  if (
@@ -426,6 +429,7 @@ export function transformMessages<TApi extends Api>(
426
429
  ) {
427
430
  sanitized = { ...sanitized, thinkingSignature: undefined };
428
431
  }
432
+ if (isOfficialAnthropicTarget && !sanitized.thinkingSignature?.trim()) return [];
429
433
  // Drop blocks with neither a signature anchor nor any text —
430
434
  // nothing for the next turn to replay.
431
435
  if (!sanitized.thinkingSignature && (!sanitized.thinking || sanitized.thinking.trim() === "")) {
@@ -433,6 +437,9 @@ export function transformMessages<TApi extends Api>(
433
437
  }
434
438
  return sanitized;
435
439
  }
440
+ // Foreign reasoning cannot be replayed natively on official Anthropic.
441
+ // Drop it before the generic cross-API path can demote it into text.
442
+ if (isOfficialAnthropicTarget) return [];
436
443
  // Cross-API target: same-model replay keeps signatures untouched
437
444
  // (the encoder needs them for native replay; an OpenAI encrypted
438
445
  // reasoning blob has empty text but a load-bearing signature).
@@ -536,12 +543,19 @@ export function transformMessages<TApi extends Api>(
536
543
  }
537
544
 
538
545
  return block;
539
- });
540
-
541
- return {
542
- ...assistantMsg,
543
- content: transformedContent,
544
546
  };
547
+
548
+ // Copy only at the first changed block; native replay usually changes nothing.
549
+ let transformedContent: AssistantMessage["content"] | undefined;
550
+ for (let blockIndex = 0; blockIndex < assistantMsg.content.length; blockIndex++) {
551
+ const block = assistantMsg.content[blockIndex]!;
552
+ const transformedBlock = transformBlock(block, blockIndex);
553
+ if (transformedBlock !== block && !transformedContent) {
554
+ transformedContent = assistantMsg.content.slice(0, blockIndex);
555
+ }
556
+ if (transformedContent && !Array.isArray(transformedBlock)) transformedContent.push(transformedBlock);
557
+ }
558
+ return transformedContent ? { ...assistantMsg, content: transformedContent } : assistantMsg;
545
559
  }
546
560
  return msg;
547
561
  });