@zenmux/rosetta-ai 1.0.24 → 1.0.25

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.
@@ -16,8 +16,6 @@ export declare class MessagesToResponsesConverter {
16
16
  private convertThinking;
17
17
  private statusToStopReason;
18
18
  private generateId;
19
- private packReasoningSignature;
20
- private unpackReasoningSignature;
21
19
  private createStreamState;
22
20
  }
23
21
  export {};
@@ -1,11 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MessagesToResponsesConverter = void 0;
4
- // The Responses backend binds a reasoning item's encrypted_content to its id, so
5
- // the id must survive the round-trip. Anthropic thinking blocks carry no id, so
6
- // we pack {id, encrypted_content} into the opaque `signature` string and unpack
7
- // it when converting the follow-up request back to Responses input.
8
- const REASONING_SIG_PREFIX = "rosetta-ai/responses-reasoning:v1:";
9
4
  class MessagesToResponsesConverter {
10
5
  streamState;
11
6
  constructor() {
@@ -81,7 +76,7 @@ class MessagesToResponsesConverter {
81
76
  content.push({
82
77
  type: "thinking",
83
78
  thinking: summaryText,
84
- signature: this.packReasoningSignature(ri.id, ri.encrypted_content),
79
+ signature: ri.encrypted_content ?? "",
85
80
  });
86
81
  }
87
82
  else if (item.type === "web_search_call" &&
@@ -306,7 +301,7 @@ class MessagesToResponsesConverter {
306
301
  index: state.currentBlockIndex,
307
302
  delta: {
308
303
  type: "signature_delta",
309
- signature: this.packReasoningSignature(ri.id, ri.encrypted_content),
304
+ signature: ri.encrypted_content,
310
305
  },
311
306
  });
312
307
  }
@@ -439,12 +434,14 @@ class MessagesToResponsesConverter {
439
434
  else {
440
435
  for (const block of msg.content) {
441
436
  if (block.type === "thinking") {
442
- const { id, encryptedContent } = this.unpackReasoningSignature(block.signature);
437
+ // ponytail: fresh reasoning id, not the backend's original. Fine for
438
+ // stateless (store:false) encrypted reasoning; if a backend rejects
439
+ // mismatched ids, the original id would need a carrier channel.
443
440
  input.push({
444
441
  type: "reasoning",
445
- id: id ?? `rs_${this.generateId()}`,
442
+ id: `rs_${this.generateId()}`,
446
443
  summary: block.thinking ? [{ type: "summary_text", text: block.thinking }] : [],
447
- encrypted_content: encryptedContent,
444
+ encrypted_content: block.signature || null,
448
445
  });
449
446
  }
450
447
  else if (block.type === "text") {
@@ -536,38 +533,6 @@ class MessagesToResponsesConverter {
536
533
  generateId() {
537
534
  return Math.random().toString(36).substring(2, 15);
538
535
  }
539
- // Encode the Responses reasoning id + encrypted_content into an opaque signature
540
- // string. Returns "" when there is no encrypted_content to preserve.
541
- packReasoningSignature(id, encryptedContent) {
542
- if (!encryptedContent)
543
- return "";
544
- const data = Buffer.from(JSON.stringify({ id, encrypted_content: encryptedContent }), "utf8").toString("base64url");
545
- return `${REASONING_SIG_PREFIX}${data}`;
546
- }
547
- // Recover { id, encrypted_content } from a packed signature. Falls back to
548
- // treating the raw signature as encrypted_content (id undefined) for
549
- // signatures not produced by this converter.
550
- unpackReasoningSignature(signature) {
551
- if (!signature)
552
- return { encryptedContent: null };
553
- if (!signature.startsWith(REASONING_SIG_PREFIX)) {
554
- return { encryptedContent: signature };
555
- }
556
- try {
557
- const encoded = signature.slice(REASONING_SIG_PREFIX.length);
558
- const parsed = JSON.parse(Buffer.from(encoded, "base64url").toString("utf8"));
559
- if (parsed && typeof parsed.encrypted_content === "string") {
560
- return {
561
- id: typeof parsed.id === "string" ? parsed.id : undefined,
562
- encryptedContent: parsed.encrypted_content,
563
- };
564
- }
565
- }
566
- catch {
567
- // fall through
568
- }
569
- return { encryptedContent: signature };
570
- }
571
536
  createStreamState() {
572
537
  return {
573
538
  id: "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenmux/rosetta-ai",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "description": "Universal translator between AI provider protocols",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",