@jacobbd/relay-ai 0.7.4 → 0.7.5

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.
@@ -11,7 +11,7 @@ import { join } from "path";
11
11
  // package.json
12
12
  var package_default = {
13
13
  name: "@jacobbd/relay-ai",
14
- version: "0.7.4",
14
+ version: "0.7.5",
15
15
  publishConfig: {
16
16
  access: "public"
17
17
  },
@@ -48,11 +48,13 @@ var package_default = {
48
48
  scripts: {
49
49
  build: "tsup && tsup --config tsup.core.config.ts && node scripts/copy-ui-assets.mjs",
50
50
  dev: "tsup --watch",
51
- test: "vitest run",
51
+ test: 'vitest run --exclude "tests/debug-*.test.ts"',
52
+ "test:live": "vitest run tests/debug-xai.test.ts tests/debug-openai-oauth.test.ts",
52
53
  "test:watch": "vitest",
53
54
  typecheck: "tsc --noEmit",
55
+ "release:check": "node scripts/release-metadata.mjs",
54
56
  "refresh:models-dev": "node scripts/refresh-models-dev-cache.mjs",
55
- prepublishOnly: `node -e "if (require('./package.json').version !== require('./package-lock.json').version) { console.error('Error: package.json and package-lock.json versions are out of sync! Run npm install to sync.'); process.exit(1); }" && npm run build`
57
+ prepublishOnly: "npm run release:check && npm run build"
56
58
  },
57
59
  dependencies: {
58
60
  "@ai-sdk/alibaba": "^1.0.26",
@@ -4174,6 +4176,10 @@ function getUiDebugLogPath() {
4174
4176
  function getServerDebugLogPath() {
4175
4177
  return join8(ensureLogsDir(), SERVER_DEBUG_LOG);
4176
4178
  }
4179
+ function getAntigravityDebugLogPath(tracePrefix) {
4180
+ const surface = tracePrefix === "antigravity" ? "app" : tracePrefix;
4181
+ return join8(ensureLogsDir(), `antigravity-${surface}-debug.log`);
4182
+ }
4177
4183
  function makeTraceLogger(logPath) {
4178
4184
  resetTraceLog(logPath);
4179
4185
  return (message) => writeSecureLogLine(logPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${message}`);
@@ -4718,6 +4724,46 @@ function serializeToolResultContent(content) {
4718
4724
  }
4719
4725
 
4720
4726
  // src/antigravity/request-adapter.ts
4727
+ function tracePartChars(part) {
4728
+ if (typeof part.text === "string") return part.text.length;
4729
+ if (part.type !== "tool-result") return void 0;
4730
+ const output = part.output;
4731
+ if (typeof output === "string") return output.length;
4732
+ if (output && typeof output === "object" && typeof output.value === "string") {
4733
+ return output.value.length;
4734
+ }
4735
+ try {
4736
+ return output === void 0 ? void 0 : JSON.stringify(output).length;
4737
+ } catch {
4738
+ return void 0;
4739
+ }
4740
+ }
4741
+ function summarizeSdkRequestForTrace(request) {
4742
+ const messages = request.messages.map((message) => {
4743
+ const content = message.content;
4744
+ if (typeof content === "string") {
4745
+ return { role: message.role, parts: [{ type: "text", chars: content.length }] };
4746
+ }
4747
+ const parts = Array.isArray(content) ? content.map((rawPart) => {
4748
+ const part = rawPart;
4749
+ const summary = {
4750
+ type: typeof part.type === "string" ? part.type : typeof rawPart
4751
+ };
4752
+ const chars = tracePartChars(part);
4753
+ if (chars !== void 0) summary.chars = chars;
4754
+ if (typeof part.toolName === "string") summary.toolName = part.toolName;
4755
+ if (typeof part.toolCallId === "string") summary.toolCallId = part.toolCallId;
4756
+ return summary;
4757
+ }) : [{ type: typeof content }];
4758
+ return { role: message.role, parts };
4759
+ });
4760
+ return {
4761
+ systemChars: request.system?.length ?? 0,
4762
+ messages,
4763
+ toolNames: Object.keys(request.tools ?? {}),
4764
+ ...request.toolChoice ? { toolChoice: request.toolChoice } : {}
4765
+ };
4766
+ }
4721
4767
  var JSON_SCHEMA_TYPES = /* @__PURE__ */ new Map([
4722
4768
  ["ARRAY", "array"],
4723
4769
  ["BOOLEAN", "boolean"],
@@ -5430,6 +5476,48 @@ function resolveUpstreamTools(tools, messages) {
5430
5476
  }
5431
5477
 
5432
5478
  // src/codex/upstream-error.ts
5479
+ var TRACE_FIELD_LIMIT = 4e3;
5480
+ function clipTraceField(value) {
5481
+ return value.length <= TRACE_FIELD_LIMIT ? value : `${value.slice(0, TRACE_FIELD_LIMIT)}\u2026`;
5482
+ }
5483
+ function safeUpstreamErrorFields(err, includeCause) {
5484
+ if (!err || typeof err !== "object") {
5485
+ return { message: clipTraceField(String(err)) };
5486
+ }
5487
+ const rec = err;
5488
+ const result = {};
5489
+ if (rec.name) result.name = rec.name;
5490
+ if (rec.message) result.message = clipTraceField(rec.message);
5491
+ if (rec.statusCode !== void 0) result.statusCode = rec.statusCode;
5492
+ if (rec.responseBody) result.responseBody = clipTraceField(rec.responseBody);
5493
+ if (rec.data?.error) {
5494
+ result.data = {
5495
+ error: {
5496
+ ...rec.data.error.type ? { type: rec.data.error.type } : {},
5497
+ ...rec.data.error.message ? { message: clipTraceField(rec.data.error.message) } : {}
5498
+ }
5499
+ };
5500
+ }
5501
+ if (rec.lastError) {
5502
+ result.lastError = {
5503
+ ...rec.lastError.message ? { message: clipTraceField(rec.lastError.message) } : {},
5504
+ ...rec.lastError.statusCode !== void 0 ? { statusCode: rec.lastError.statusCode } : {}
5505
+ };
5506
+ }
5507
+ if (rec.errors?.length) {
5508
+ result.errors = rec.errors.map((item) => ({
5509
+ ...item.message ? { message: clipTraceField(item.message) } : {},
5510
+ ...item.statusCode !== void 0 ? { statusCode: item.statusCode } : {}
5511
+ }));
5512
+ }
5513
+ if (includeCause && rec.cause !== void 0) {
5514
+ result.cause = safeUpstreamErrorFields(rec.cause, false);
5515
+ }
5516
+ return result;
5517
+ }
5518
+ function formatUpstreamErrorTrace(err) {
5519
+ return JSON.stringify(safeUpstreamErrorFields(err, true));
5520
+ }
5433
5521
  function formatUpstreamError(err) {
5434
5522
  if (!err || typeof err !== "object") return "Upstream model request failed.";
5435
5523
  const rec = err;
@@ -11973,6 +12061,7 @@ export {
11973
12061
  getGeminiProxyDebugLogPath,
11974
12062
  getUiDebugLogPath,
11975
12063
  getServerDebugLogPath,
12064
+ getAntigravityDebugLogPath,
11976
12065
  makeTraceLogger,
11977
12066
  writeSecureLogLine,
11978
12067
  printTraceLog,
@@ -12004,7 +12093,9 @@ export {
12004
12093
  splitToolUseId,
12005
12094
  encodeToolUseId,
12006
12095
  serializeToolResultContent,
12096
+ summarizeSdkRequestForTrace,
12007
12097
  translateRequest,
12098
+ formatUpstreamErrorTrace,
12008
12099
  formatUpstreamError,
12009
12100
  upstreamHttpStatus,
12010
12101
  aliasModelId,
@@ -12071,4 +12162,4 @@ export {
12071
12162
  supportsClaudeTransparentMode,
12072
12163
  buildHttpProxyRoutes
12073
12164
  };
12074
- //# sourceMappingURL=chunk-EUY2MVOS.js.map
12165
+ //# sourceMappingURL=chunk-HEMJFOXG.js.map