@opengeni/codex 0.2.10 → 0.2.11

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.ts CHANGED
@@ -11,5 +11,6 @@ export * from "./response-timeout";
11
11
  export * from "./fetch";
12
12
  export * from "./mcp-sanitize";
13
13
  export * from "./model-output-truncation";
14
+ export * from "./opaque-artifact";
14
15
  export * from "./realtime";
15
16
  export * from "./realtime-v3";
package/dist/index.js CHANGED
@@ -786,6 +786,27 @@ function isPreHeadersTimeoutError(error) {
786
786
 
787
787
  // src/fetch.ts
788
788
  import { randomUUID } from "crypto";
789
+
790
+ // src/opaque-artifact.ts
791
+ import { createHash } from "crypto";
792
+ function opaqueProviderArtifactFingerprint(item) {
793
+ if (!item || typeof item !== "object") return null;
794
+ const record = item;
795
+ if (record.type !== "reasoning" && record.type !== "compaction") return null;
796
+ const providerData = record.providerData && typeof record.providerData === "object" ? record.providerData : null;
797
+ const ciphertext = typeof record.encrypted_content === "string" && record.encrypted_content || typeof record.encryptedContent === "string" && record.encryptedContent || typeof providerData?.encrypted_content === "string" && providerData.encrypted_content || typeof providerData?.encryptedContent === "string" && providerData.encryptedContent || null;
798
+ if (!ciphertext) return null;
799
+ return `${record.type}:${createHash("sha256").update(ciphertext).digest("hex")}`;
800
+ }
801
+ function opaqueProviderArtifactFingerprints(input) {
802
+ if (!Array.isArray(input)) return [];
803
+ return input.flatMap((item) => {
804
+ const fingerprint = opaqueProviderArtifactFingerprint(item);
805
+ return fingerprint ? [fingerprint] : [];
806
+ });
807
+ }
808
+
809
+ // src/fetch.ts
789
810
  var CODEX_TRANSPORT_ERROR_HEADER = "x-opengeni-codex-transport-error";
790
811
  function headersCarryCodexTransportMarker(headers) {
791
812
  if (!headers || typeof headers !== "object") return false;
@@ -1122,6 +1143,7 @@ function codexSubscriptionFetch(base = globalThis.fetch) {
1122
1143
  }
1123
1144
  let callerWantsStream = true;
1124
1145
  let model;
1146
+ let requestOpaqueArtifacts = [];
1125
1147
  const nextInit = { ...init, headers };
1126
1148
  if (typeof init?.body === "string") {
1127
1149
  try {
@@ -1130,9 +1152,11 @@ function codexSubscriptionFetch(base = globalThis.fetch) {
1130
1152
  const normalized = normalizeCodexRequestBody(parsed, ctx.resolveModel);
1131
1153
  model = typeof normalized.model === "string" ? normalized.model : void 0;
1132
1154
  nextInit.body = JSON.stringify(normalized);
1155
+ requestOpaqueArtifacts = opaqueProviderArtifactFingerprints(normalized.input);
1133
1156
  } catch {
1134
1157
  }
1135
1158
  }
1159
+ ctx.onRequestOpaqueArtifacts?.({ requestId, fingerprints: requestOpaqueArtifacts });
1136
1160
  headers.set(
1137
1161
  "Idempotency-Key",
1138
1162
  authenticationAttempt === 0 ? requestId : `${requestId}:auth-${authenticationAttempt}`
@@ -2607,6 +2631,8 @@ export {
2607
2631
  modelToolOutputSerializationBudgetTokens,
2608
2632
  normalizeCodexRequestBody,
2609
2633
  normalizeCodexUsage,
2634
+ opaqueProviderArtifactFingerprint,
2635
+ opaqueProviderArtifactFingerprints,
2610
2636
  parseCodexRateLimitResetConsumeResponse,
2611
2637
  parseCodexRateLimitResetCreditsDetails,
2612
2638
  parseCodexRateLimitResetCreditsSummary,