@anthonyhaussman/opencode-agy-auth 1.2.3-alpha.8 → 1.2.3-alpha.9

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
@@ -21175,6 +21175,7 @@ async function setupOpenCodeV2(ctx) {
21175
21175
  event.options.apiKey = "dummy";
21176
21176
  event.options.fetch = createV2FetchInterceptor();
21177
21177
  });
21178
+ let lastInterceptedModel;
21178
21179
  ctx.session.hook(
21179
21180
  "http.request",
21180
21181
  async (event) => {
@@ -21209,6 +21210,9 @@ async function setupOpenCodeV2(ctx) {
21209
21210
  if (isGL) {
21210
21211
  const parsed = parseGenerativeLanguageRequest(rawUrl);
21211
21212
  modelName = parsed?.effectiveModel;
21213
+ if (modelName) {
21214
+ lastInterceptedModel = modelName;
21215
+ }
21212
21216
  if (typeof event.headers.delete === "function") {
21213
21217
  event.headers.delete("x-goog-api-key");
21214
21218
  event.headers.delete("api-key");
@@ -21415,8 +21419,8 @@ async function setupOpenCodeV2(ctx) {
21415
21419
  const isInternal = rawUrl.includes("cloudcode-pa.googleapis.com");
21416
21420
  if (isInternal && event.response instanceof Response) {
21417
21421
  const isStreaming = rawUrl.includes(":streamGenerateCode") || event.response.headers.get("content-type")?.includes("text/event-stream");
21418
- const parsedModel = parseGenerativeLanguageRequest(rawUrl)?.effectiveModel;
21419
- const transformed = transformAgyResponse(
21422
+ const parsedModel = parseGenerativeLanguageRequest(rawUrl)?.effectiveModel || lastInterceptedModel;
21423
+ const transformed = await transformAgyResponse(
21420
21424
  event.response,
21421
21425
  !!isStreaming,
21422
21426
  null,