@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 +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp-sanitize.d.ts +4 -3
- package/dist/opaque-artifact.d.ts +4 -0
- package/dist/request-context.d.ts +6 -0
- package/package.json +1 -1
- package/src/fetch.ts +4 -0
- package/src/index.ts +1 -0
- package/src/mcp-sanitize.ts +5 -4
- package/src/normalize.ts +1 -1
- package/src/opaque-artifact.ts +29 -0
- package/src/request-context.ts +7 -0
package/dist/index.d.ts
CHANGED
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,
|