@opengeni/codex 0.2.11 → 0.2.13
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/fetch.d.ts +4 -4
- package/dist/index.js +24 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/fetch.ts +20 -23
- package/src/mcp-sanitize.ts +12 -8
package/dist/fetch.d.ts
CHANGED
|
@@ -67,9 +67,9 @@ export type CodexSseFailureProjection = {
|
|
|
67
67
|
* A provider terminal carried inside an accepted HTTP-200 stream. The OpenAI
|
|
68
68
|
* SDK cannot turn that late terminal into a non-2xx APIError because headers
|
|
69
69
|
* have already been accepted, so the body transform throws this equivalent
|
|
70
|
-
* bounded shape. Provider-supplied message/param text
|
|
71
|
-
*
|
|
72
|
-
*
|
|
70
|
+
* bounded shape. Provider-supplied message/param text remains exact within the
|
|
71
|
+
* explicit terminal-field byte contract; retry classification is additive and
|
|
72
|
+
* never substitutes for the source diagnostic.
|
|
73
73
|
*/
|
|
74
74
|
export declare class CodexStreamingTerminalError extends Error {
|
|
75
75
|
readonly status: number;
|
|
@@ -80,5 +80,5 @@ export declare class CodexStreamingTerminalError extends Error {
|
|
|
80
80
|
readonly responseStatus?: string;
|
|
81
81
|
readonly headers: Headers;
|
|
82
82
|
readonly error: Record<string, unknown>;
|
|
83
|
-
constructor(projection: CodexSseFailureProjection
|
|
83
|
+
constructor(projection: CodexSseFailureProjection);
|
|
84
84
|
}
|
package/dist/index.js
CHANGED
|
@@ -1162,16 +1162,12 @@ function codexSubscriptionFetch(base = globalThis.fetch) {
|
|
|
1162
1162
|
authenticationAttempt === 0 ? requestId : `${requestId}:auth-${authenticationAttempt}`
|
|
1163
1163
|
);
|
|
1164
1164
|
if (process.env.CODEX_DEBUG) {
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
}
|
|
1172
|
-
console.error(
|
|
1173
|
-
`[codex-debug] POST ${rewritten} stream=${callerWantsStream} bodyKeys=[${keys.join(",")}]`
|
|
1174
|
-
);
|
|
1165
|
+
console.error("[codex-debug] request dispatched", {
|
|
1166
|
+
method: "POST",
|
|
1167
|
+
origin: "codex-subscription",
|
|
1168
|
+
route: "codex_responses",
|
|
1169
|
+
stream: callerWantsStream
|
|
1170
|
+
});
|
|
1175
1171
|
}
|
|
1176
1172
|
let res;
|
|
1177
1173
|
transportAttempt += 1;
|
|
@@ -1228,9 +1224,11 @@ function codexSubscriptionFetch(base = globalThis.fetch) {
|
|
|
1228
1224
|
ctx.onUsageHeaders?.(usage);
|
|
1229
1225
|
}
|
|
1230
1226
|
if (process.env.CODEX_DEBUG && !res.ok) {
|
|
1231
|
-
console.error(
|
|
1232
|
-
|
|
1233
|
-
|
|
1227
|
+
console.error("[codex-debug] request failed", {
|
|
1228
|
+
origin: "codex-subscription",
|
|
1229
|
+
route: "codex_responses",
|
|
1230
|
+
status: res.status
|
|
1231
|
+
});
|
|
1234
1232
|
}
|
|
1235
1233
|
if (!res.ok) {
|
|
1236
1234
|
return await bufferCodexErrorResponse(res);
|
|
@@ -1492,8 +1490,8 @@ var CodexStreamingTerminalError = class extends Error {
|
|
|
1492
1490
|
responseStatus;
|
|
1493
1491
|
headers;
|
|
1494
1492
|
error;
|
|
1495
|
-
constructor(projection
|
|
1496
|
-
super(
|
|
1493
|
+
constructor(projection) {
|
|
1494
|
+
super(projection.error.message);
|
|
1497
1495
|
this.name = "CodexStreamingTerminalError";
|
|
1498
1496
|
this.status = projection.status;
|
|
1499
1497
|
this.code = projection.error.code;
|
|
@@ -1511,6 +1509,8 @@ var CodexStreamingTerminalError = class extends Error {
|
|
|
1511
1509
|
this.error = {
|
|
1512
1510
|
type: projection.error.type,
|
|
1513
1511
|
code: projection.error.code,
|
|
1512
|
+
message: projection.error.message,
|
|
1513
|
+
...projection.error.param ? { param: projection.error.param } : {},
|
|
1514
1514
|
...projection.error.event_type ? { event_type: projection.error.event_type } : {},
|
|
1515
1515
|
...projection.error.response_id ? { response_id: projection.error.response_id } : {},
|
|
1516
1516
|
...projection.error.response_status ? { response_status: projection.error.response_status } : {},
|
|
@@ -1520,8 +1520,7 @@ var CodexStreamingTerminalError = class extends Error {
|
|
|
1520
1520
|
};
|
|
1521
1521
|
function codexSseFailureError(source, rawError, fallbackCode, publicMessage, metadata = {}) {
|
|
1522
1522
|
return new CodexStreamingTerminalError(
|
|
1523
|
-
codexSseFailureProjection(source, rawError, fallbackCode, publicMessage, metadata)
|
|
1524
|
-
publicMessage
|
|
1523
|
+
codexSseFailureProjection(source, rawError, fallbackCode, publicMessage, metadata)
|
|
1525
1524
|
);
|
|
1526
1525
|
}
|
|
1527
1526
|
function repairCodexStream(res) {
|
|
@@ -1786,13 +1785,15 @@ function inlineStructuredContentInRpcMessage(message) {
|
|
|
1786
1785
|
return;
|
|
1787
1786
|
}
|
|
1788
1787
|
const structured = record.structuredContent;
|
|
1789
|
-
if (structured
|
|
1790
|
-
|
|
1788
|
+
if (structured !== void 0 && structured !== null) {
|
|
1789
|
+
const text = typeof structured === "string" ? structured : JSON.stringify(structured);
|
|
1790
|
+
const content = Array.isArray(record.content) ? [...record.content] : [];
|
|
1791
|
+
content.push({ type: "text", text });
|
|
1792
|
+
record.content = content;
|
|
1793
|
+
}
|
|
1794
|
+
if (typeof structured !== "object" || structured === null || Array.isArray(structured)) {
|
|
1795
|
+
delete record.structuredContent;
|
|
1791
1796
|
}
|
|
1792
|
-
const text = typeof structured === "string" ? structured : JSON.stringify(structured);
|
|
1793
|
-
const content = Array.isArray(record.content) ? [...record.content] : [];
|
|
1794
|
-
content.push({ type: "text", text });
|
|
1795
|
-
record.content = content;
|
|
1796
1797
|
}
|
|
1797
1798
|
function sanitizeMcpJsonBody(text, mapper = new ToolNameMapper(), namespaceSink) {
|
|
1798
1799
|
try {
|