billion-context 0.1.47-pr.215.29 → 0.1.47
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.js +2 -40
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -50048,19 +50048,6 @@ async function* runCompressLoop(upstream, ctx, requestBody, requestOptions, adap
|
|
|
50048
50048
|
}
|
|
50049
50049
|
|
|
50050
50050
|
// src/loop/adapter-responses.ts
|
|
50051
|
-
function rewriteItemEvent(type, obj, mapped) {
|
|
50052
|
-
const item = { ...obj.item ?? {}, id: mapped.id };
|
|
50053
|
-
return Buffer.from(`event: ${type}
|
|
50054
|
-
data: ${JSON.stringify({ ...obj, output_index: mapped.index, item })}
|
|
50055
|
-
|
|
50056
|
-
`, "utf8");
|
|
50057
|
-
}
|
|
50058
|
-
function rewriteRefEvent(type, obj, mapped) {
|
|
50059
|
-
return Buffer.from(`event: ${type}
|
|
50060
|
-
data: ${JSON.stringify({ ...obj, item_id: mapped.id, output_index: mapped.index })}
|
|
50061
|
-
|
|
50062
|
-
`, "utf8");
|
|
50063
|
-
}
|
|
50064
50051
|
async function* iterSseEvents(stream2) {
|
|
50065
50052
|
const reader = stream2.getReader();
|
|
50066
50053
|
let buf = "";
|
|
@@ -50226,7 +50213,6 @@ function createResponsesAdapter(textProtocol, projection) {
|
|
|
50226
50213
|
},
|
|
50227
50214
|
async *parseStream(upstream, round) {
|
|
50228
50215
|
const pending = /* @__PURE__ */ new Map();
|
|
50229
|
-
const remapped = /* @__PURE__ */ new Map();
|
|
50230
50216
|
for await (const eventStr of iterSseEvents(upstream)) {
|
|
50231
50217
|
const type = extractEventType(eventStr);
|
|
50232
50218
|
const dataLine = extractDataLine(eventStr);
|
|
@@ -50260,32 +50246,17 @@ function createResponsesAdapter(textProtocol, projection) {
|
|
|
50260
50246
|
}
|
|
50261
50247
|
} else if (item?.type === "custom_tool_call") {
|
|
50262
50248
|
yield { kind: "meta", chunk: rawBuf, firstRoundOnly: false };
|
|
50263
|
-
} else if (item?.type === "message" && round > 1 && !suppressTextLifecycle) {
|
|
50264
|
-
const origId = typeof item.id === "string" ? item.id : "";
|
|
50265
|
-
const mapped = { id: `msg-proxy-${round}-${origId || outputIndex}`, index: outputIndex++ };
|
|
50266
|
-
if (origId) remapped.set(origId, mapped);
|
|
50267
|
-
yield { kind: "meta", chunk: rewriteItemEvent(type, obj, mapped), firstRoundOnly: false };
|
|
50268
50249
|
} else if (item?.type !== "message" || !suppressTextLifecycle) {
|
|
50269
50250
|
yield { kind: "meta", chunk: rawBuf, firstRoundOnly: true };
|
|
50270
50251
|
}
|
|
50271
50252
|
} else if (type === "response.content_part.added" || type === "response.content_part.done" || type === "response.output_text.done") {
|
|
50272
|
-
|
|
50273
|
-
if (mapped) {
|
|
50274
|
-
yield { kind: "meta", chunk: rewriteRefEvent(type, obj, mapped), firstRoundOnly: false };
|
|
50275
|
-
} else if (!suppressTextLifecycle) {
|
|
50253
|
+
if (!suppressTextLifecycle) {
|
|
50276
50254
|
yield { kind: "meta", chunk: rawBuf, firstRoundOnly: true };
|
|
50277
50255
|
}
|
|
50278
50256
|
} else if (type === "response.output_text.delta") {
|
|
50279
50257
|
const delta = typeof obj.delta === "string" ? obj.delta : "";
|
|
50280
50258
|
if (delta.length > 0) {
|
|
50281
|
-
|
|
50282
|
-
if (mapped) {
|
|
50283
|
-
yield { kind: "text", delta, raw: rewriteRefEvent(type, obj, mapped) };
|
|
50284
|
-
} else if (round === 1) {
|
|
50285
|
-
yield { kind: "text", delta, raw: rawBuf };
|
|
50286
|
-
} else {
|
|
50287
|
-
yield { kind: "text", delta };
|
|
50288
|
-
}
|
|
50259
|
+
yield { kind: "text", delta, raw: rawBuf };
|
|
50289
50260
|
}
|
|
50290
50261
|
} else if (type === "response.function_call_arguments.delta") {
|
|
50291
50262
|
const itemId = typeof obj.item_id === "string" ? obj.item_id : "";
|
|
@@ -50325,15 +50296,6 @@ function createResponsesAdapter(textProtocol, projection) {
|
|
|
50325
50296
|
}
|
|
50326
50297
|
} else if (item?.type === "custom_tool_call") {
|
|
50327
50298
|
yield { kind: "meta", chunk: rawBuf, firstRoundOnly: false };
|
|
50328
|
-
} else if (item?.type === "message") {
|
|
50329
|
-
const origId = typeof item.id === "string" ? item.id : "";
|
|
50330
|
-
const mapped = remapped.get(origId);
|
|
50331
|
-
if (mapped) {
|
|
50332
|
-
remapped.delete(origId);
|
|
50333
|
-
yield { kind: "meta", chunk: rewriteItemEvent(type, obj, mapped), firstRoundOnly: false };
|
|
50334
|
-
} else if (!suppressTextLifecycle) {
|
|
50335
|
-
yield { kind: "meta", chunk: rawBuf, firstRoundOnly: true };
|
|
50336
|
-
}
|
|
50337
50299
|
} else if (item?.type !== "message" || !suppressTextLifecycle) {
|
|
50338
50300
|
yield { kind: "meta", chunk: rawBuf, firstRoundOnly: true };
|
|
50339
50301
|
}
|