@jacobbd/relay-ai 0.7.5 → 0.7.6

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/cli.js CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  GLOBAL_OPENCODE_KEYRING_ACCOUNT,
9
9
  MAX_MODEL_CATALOG,
10
10
  PREVIEW_PROXY_PORT,
11
+ UNSUPPORTED_VOICE_MESSAGE,
11
12
  VERSION,
12
13
  VERTEX_ANTHROPIC_NPM,
13
14
  addCustomEndpointProvider,
@@ -154,6 +155,7 @@ import {
154
155
  routableModelsForTarget,
155
156
  routeLookupIds,
156
157
  runServerCommand,
158
+ sanitizeUnsupportedInlineData,
157
159
  savePreferences,
158
160
  saveProviderCredential,
159
161
  saveRegistry,
@@ -180,7 +182,7 @@ import {
180
182
  validateCustomEndpointUrl,
181
183
  writeSecureLogLine,
182
184
  zenRegistryStub
183
- } from "./chunk-HEMJFOXG.js";
185
+ } from "./chunk-GHSURQOK.js";
184
186
  import {
185
187
  filterTemplates,
186
188
  init_provider_templates,
@@ -7547,7 +7549,12 @@ async function startCloudCodeGateway(routes, opts = {}) {
7547
7549
  } catch {
7548
7550
  }
7549
7551
  if (trace && parsed) {
7550
- const preview = JSON.stringify(parsed).slice(0, 500);
7552
+ const preview = JSON.stringify(parsed, function(key, value) {
7553
+ if (key === "data" && typeof value === "string" && this && typeof this === "object" && typeof this.mimeType === "string") {
7554
+ return `[${value.length} media chars]`;
7555
+ }
7556
+ return value;
7557
+ }).slice(0, 500);
7551
7558
  log14(`[gateway] body-preview: ${preview}`);
7552
7559
  }
7553
7560
  if (lowerUrl.includes("loadcodeassist")) {
@@ -7575,6 +7582,13 @@ async function startCloudCodeGateway(routes, opts = {}) {
7575
7582
  `[gateway] resolved route: ${route.catalogId} (${route.providerId}/${route.upstreamModelId} via ${model})`
7576
7583
  );
7577
7584
  }
7585
+ const media = sanitizeUnsupportedInlineData(parsed);
7586
+ parsed = media.request;
7587
+ if (media.latestUserTurnHasUnsupportedMedia) {
7588
+ if (trace) log14("[gateway] unsupported media in current user turn; provider call skipped");
7589
+ respondUnsupportedMedia(res, route, lowerUrl.includes("stream"));
7590
+ return;
7591
+ }
7578
7592
  if (trackActiveRoute && selectedSlotIds.has(model ?? "") && isUserTurnRequest(parsed)) {
7579
7593
  activeRoute = route;
7580
7594
  if (trace) log14(`[gateway] active route: ${route.catalogId} via ${model}`);
@@ -7944,6 +7958,41 @@ function respondJson(res, status, data) {
7944
7958
  });
7945
7959
  res.end(body);
7946
7960
  }
7961
+ function respondUnsupportedMedia(res, route, streaming) {
7962
+ const responseId = `relay-${Date.now()}`;
7963
+ if (streaming) {
7964
+ const chunk = formatCloudCodeChunk({
7965
+ text: UNSUPPORTED_VOICE_MESSAGE,
7966
+ modelVersion: route.catalogId,
7967
+ responseId,
7968
+ finishReason: "STOP"
7969
+ });
7970
+ res.writeHead(200, {
7971
+ "content-type": "text/event-stream",
7972
+ "cache-control": "no-cache",
7973
+ "grpc-status": "0"
7974
+ });
7975
+ res.end(`data: ${JSON.stringify(chunk)}
7976
+
7977
+ `);
7978
+ return;
7979
+ }
7980
+ respondJson(res, 200, {
7981
+ response: {
7982
+ candidates: [{
7983
+ content: {
7984
+ role: "model",
7985
+ parts: [{ text: UNSUPPORTED_VOICE_MESSAGE }]
7986
+ },
7987
+ finishReason: "STOP"
7988
+ }],
7989
+ modelVersion: route.catalogId,
7990
+ responseId
7991
+ },
7992
+ traceId: "relay-trace",
7993
+ metadata: {}
7994
+ });
7995
+ }
7947
7996
  function parsePseudoToolCall(text4, knownToolNames) {
7948
7997
  const trimmed = text4.trim();
7949
7998
  if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) return null;
@@ -13443,7 +13492,7 @@ Options:
13443
13492
  --trace Write debug logs under ~/.relay-ai/logs/`);
13444
13493
  return 0;
13445
13494
  }
13446
- const { runUiCommand } = await import("./ui-command-26QQUWTQ.js");
13495
+ const { runUiCommand } = await import("./ui-command-27X4WJKC.js");
13447
13496
  return runUiCommand({ trace: parsed.trace, serverMode: parsed.uiServerMode });
13448
13497
  }
13449
13498
  if (parsed.command === "models") {