billion-context 0.1.29 → 0.1.30

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 CHANGED
@@ -49752,6 +49752,17 @@ data: ${JSON.stringify({
49752
49752
  response: resp
49753
49753
  })}
49754
49754
 
49755
+ `;
49756
+ }
49757
+ function buildFailed(responseObj) {
49758
+ const id = responseObj?.id ?? `resp-failed-${Date.now()}`;
49759
+ const resp = { ...responseObj ?? {}, id, status: "failed", error: { code: "server_error", message: "upstream returned empty response" } };
49760
+ return `event: response.failed
49761
+ data: ${JSON.stringify({
49762
+ type: "response.failed",
49763
+ response: resp
49764
+ })}
49765
+
49755
49766
  `;
49756
49767
  }
49757
49768
  function responsesJsonOutput(response) {
@@ -49955,7 +49966,13 @@ async function* compressLoopResponsesStream(initialUpstream, ctx, requestBody, r
49955
49966
  yield Buffer.from(terminalRaw + "\n\n", "utf8");
49956
49967
  return;
49957
49968
  }
49958
- if (!completed && contentText.length === 0 && realCalls.length === 0) {
49969
+ const hasUsage = !!responseObj?.usage;
49970
+ if (contentText.length === 0 && realCalls.length === 0 && customToolCalls === 0 && !hasUsage) {
49971
+ ctx.log("[acp-proxy: empty upstream response (no content/usage) \u2014 injecting response.failed for client retry]");
49972
+ yield Buffer.from(buildFailed(responseObj), "utf8");
49973
+ return;
49974
+ }
49975
+ if (!completed) {
49959
49976
  ctx.log("[acp-proxy: responses stream ended without completion]");
49960
49977
  }
49961
49978
  yield Buffer.from(buildCompleted(responseObj), "utf8");