@jacobbd/relay-ai 0.7.3 → 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.
- package/dist/{chunk-5LPUIWNJ.js → chunk-HEMJFOXG.js} +100 -7
- package/dist/chunk-HEMJFOXG.js.map +1 -0
- package/dist/cli.js +89 -34
- package/dist/cli.js.map +1 -1
- package/dist/core/index.js +7 -3
- package/dist/core/index.js.map +1 -1
- package/dist/{ui-command-DMPYSK7W.js → ui-command-26QQUWTQ.js} +2 -2
- package/package.json +7 -3
- package/dist/chunk-5LPUIWNJ.js.map +0 -1
- /package/dist/{ui-command-DMPYSK7W.js.map → ui-command-26QQUWTQ.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -69,6 +69,8 @@ import {
|
|
|
69
69
|
formatRegistryAuthLabel,
|
|
70
70
|
formatUpdateNotification,
|
|
71
71
|
formatUpstreamError,
|
|
72
|
+
formatUpstreamErrorTrace,
|
|
73
|
+
getAntigravityDebugLogPath,
|
|
72
74
|
getAppHome,
|
|
73
75
|
getAppPathOverride,
|
|
74
76
|
getClaudeDebugLogPath,
|
|
@@ -167,6 +169,7 @@ import {
|
|
|
167
169
|
startProxy,
|
|
168
170
|
startProxyCatalog,
|
|
169
171
|
startServer,
|
|
172
|
+
summarizeSdkRequestForTrace,
|
|
170
173
|
supportsClaudeTransparentMode,
|
|
171
174
|
supportsNativeOAuth,
|
|
172
175
|
syntheticTemplate,
|
|
@@ -177,7 +180,7 @@ import {
|
|
|
177
180
|
validateCustomEndpointUrl,
|
|
178
181
|
writeSecureLogLine,
|
|
179
182
|
zenRegistryStub
|
|
180
|
-
} from "./chunk-
|
|
183
|
+
} from "./chunk-HEMJFOXG.js";
|
|
181
184
|
import {
|
|
182
185
|
filterTemplates,
|
|
183
186
|
init_provider_templates,
|
|
@@ -2342,6 +2345,9 @@ function newResponseId() {
|
|
|
2342
2345
|
function newItemId(prefix) {
|
|
2343
2346
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
|
|
2344
2347
|
}
|
|
2348
|
+
function functionCallItemId(upstreamId) {
|
|
2349
|
+
return upstreamId.startsWith("fc_") ? upstreamId : newItemId("fc");
|
|
2350
|
+
}
|
|
2345
2351
|
function usageFromPart(part) {
|
|
2346
2352
|
const input = part.totalUsage?.inputTokens ?? 0;
|
|
2347
2353
|
const output = part.totalUsage?.outputTokens ?? 0;
|
|
@@ -2441,10 +2447,11 @@ async function writeResponsesStream(fullStream, modelId, write, onDone, onProgre
|
|
|
2441
2447
|
return state;
|
|
2442
2448
|
};
|
|
2443
2449
|
const createToolState = (rawId, name, signature) => {
|
|
2444
|
-
const
|
|
2450
|
+
const upstreamId = rawId ?? newItemId("call");
|
|
2451
|
+
const itemId = functionCallItemId(upstreamId);
|
|
2445
2452
|
const state = rememberToolState({
|
|
2446
2453
|
itemId,
|
|
2447
|
-
callId: encodeToolUseId(
|
|
2454
|
+
callId: encodeToolUseId(upstreamId, signature, false),
|
|
2448
2455
|
name: name ?? "unknown",
|
|
2449
2456
|
outputIndex: outputIndex++,
|
|
2450
2457
|
args: ""
|
|
@@ -2828,7 +2835,13 @@ async function generateResponsesResponse(model, params, modelId) {
|
|
|
2828
2835
|
for (const tc of r.toolCalls) {
|
|
2829
2836
|
const encodedId = encodeToolUseId(tc.toolCallId, grabRoundTripSignature(tc), false);
|
|
2830
2837
|
const argsStr = JSON.stringify(tc.input ?? {});
|
|
2831
|
-
output.push(buildFinalToolItem(
|
|
2838
|
+
output.push(buildFinalToolItem(
|
|
2839
|
+
resolveOutputKind(tc.toolName, toolContext),
|
|
2840
|
+
tc.toolName,
|
|
2841
|
+
encodedId,
|
|
2842
|
+
functionCallItemId(tc.toolCallId),
|
|
2843
|
+
argsStr
|
|
2844
|
+
));
|
|
2832
2845
|
}
|
|
2833
2846
|
if (output.length === 0) {
|
|
2834
2847
|
output.push({ id: newItemId("msg"), type: "message", role: "assistant", status: "completed", content: [{ type: "output_text", text: "(conversation context was too large to summarize)" }] });
|
|
@@ -6416,7 +6429,6 @@ Error: ${launchPlan.error}
|
|
|
6416
6429
|
// src/antigravity.ts
|
|
6417
6430
|
import pc9 from "picocolors";
|
|
6418
6431
|
import * as p11 from "@clack/prompts";
|
|
6419
|
-
import { appendFileSync as appendFileSync2 } from "fs";
|
|
6420
6432
|
|
|
6421
6433
|
// src/antigravity/cloud-code-gateway.ts
|
|
6422
6434
|
import http from "http";
|
|
@@ -7558,6 +7570,11 @@ async function startCloudCodeGateway(routes, opts = {}) {
|
|
|
7558
7570
|
if (trace) log14(`[gateway] extracted model: ${model ?? "N/A"}`);
|
|
7559
7571
|
const route = resolveRouteForModel(model);
|
|
7560
7572
|
if (route) {
|
|
7573
|
+
if (trace) {
|
|
7574
|
+
log14(
|
|
7575
|
+
`[gateway] resolved route: ${route.catalogId} (${route.providerId}/${route.upstreamModelId} via ${model})`
|
|
7576
|
+
);
|
|
7577
|
+
}
|
|
7561
7578
|
if (trackActiveRoute && selectedSlotIds.has(model ?? "") && isUserTurnRequest(parsed)) {
|
|
7562
7579
|
activeRoute = route;
|
|
7563
7580
|
if (trace) log14(`[gateway] active route: ${route.catalogId} via ${model}`);
|
|
@@ -7584,9 +7601,11 @@ async function startCloudCodeGateway(routes, opts = {}) {
|
|
|
7584
7601
|
if (isStream) {
|
|
7585
7602
|
handleStreamingRequest(res, route, baseProviderOptions, parsed, log14, {
|
|
7586
7603
|
requestOptions,
|
|
7587
|
-
onReasoningWithToolCall: rememberReasoning
|
|
7604
|
+
onReasoningWithToolCall: rememberReasoning,
|
|
7605
|
+
trace
|
|
7588
7606
|
}).catch((err) => {
|
|
7589
|
-
log14(`[gateway] stream error: ${
|
|
7607
|
+
log14(`[gateway] stream error: ${formatUpstreamError(err)}`);
|
|
7608
|
+
if (trace) log14(`[gateway] stream error detail: ${formatUpstreamErrorTrace(err)}`);
|
|
7590
7609
|
if (!res.headersSent) {
|
|
7591
7610
|
respondJson(res, 500, { error: { code: 500, message: formatUpstreamError(err) } });
|
|
7592
7611
|
} else if (!res.writableEnded) {
|
|
@@ -7596,9 +7615,11 @@ async function startCloudCodeGateway(routes, opts = {}) {
|
|
|
7596
7615
|
} else {
|
|
7597
7616
|
handleUnaryRequest(res, route, baseProviderOptions, parsed, log14, {
|
|
7598
7617
|
requestOptions,
|
|
7599
|
-
onReasoningWithToolCall: rememberReasoning
|
|
7618
|
+
onReasoningWithToolCall: rememberReasoning,
|
|
7619
|
+
trace
|
|
7600
7620
|
}).catch((err) => {
|
|
7601
|
-
log14(`[gateway] unary error: ${
|
|
7621
|
+
log14(`[gateway] unary error: ${formatUpstreamError(err)}`);
|
|
7622
|
+
if (trace) log14(`[gateway] unary error detail: ${formatUpstreamErrorTrace(err)}`);
|
|
7602
7623
|
if (!res.headersSent) {
|
|
7603
7624
|
respondJson(res, 500, { error: { code: 500, message: formatUpstreamError(err) } });
|
|
7604
7625
|
}
|
|
@@ -7766,7 +7787,7 @@ function shouldEchoReasoningForRoute(route) {
|
|
|
7766
7787
|
route.displayName,
|
|
7767
7788
|
route.baseURL
|
|
7768
7789
|
].join(" ");
|
|
7769
|
-
return /deepseek/i.test(routeIdentity);
|
|
7790
|
+
return /deepseek|big[\s_-]?pickle|\bglm[\s_-]/i.test(routeIdentity);
|
|
7770
7791
|
}
|
|
7771
7792
|
function reasoningEchoOptionsForRoute(route, parsed, cache) {
|
|
7772
7793
|
if (!shouldEchoReasoningForRoute(route)) return {};
|
|
@@ -7944,6 +7965,9 @@ async function handleStreamingRequest(res, route, providerOptions, parsed, log14
|
|
|
7944
7965
|
...options.requestOptions,
|
|
7945
7966
|
maxTools: maxToolsForNpm(route.npm)
|
|
7946
7967
|
}));
|
|
7968
|
+
if (options.trace) {
|
|
7969
|
+
log14(`[gateway] sdk request: ${JSON.stringify(summarizeSdkRequestForTrace(sdkParams))}`);
|
|
7970
|
+
}
|
|
7947
7971
|
const effectiveProviderOptions = deepMergeProviderOptions(
|
|
7948
7972
|
providerOptions,
|
|
7949
7973
|
sdkParams.providerOptions
|
|
@@ -8104,6 +8128,9 @@ async function handleStreamingRequest(res, route, providerOptions, parsed, log14
|
|
|
8104
8128
|
} else if (p15.type === "error") {
|
|
8105
8129
|
const message = formatUpstreamError(p15.error);
|
|
8106
8130
|
log14(`[gateway] stream provider error: ${message}`);
|
|
8131
|
+
if (options.trace) {
|
|
8132
|
+
log14(`[gateway] stream provider error detail: ${formatUpstreamErrorTrace(p15.error)}`);
|
|
8133
|
+
}
|
|
8107
8134
|
flushBufferedText();
|
|
8108
8135
|
emitStreamError(res, route, responseId, message, startSse);
|
|
8109
8136
|
break;
|
|
@@ -8119,11 +8146,14 @@ async function handleStreamingRequest(res, route, providerOptions, parsed, log14
|
|
|
8119
8146
|
}
|
|
8120
8147
|
res.end();
|
|
8121
8148
|
}
|
|
8122
|
-
async function handleUnaryRequest(res, route, providerOptions, parsed,
|
|
8149
|
+
async function handleUnaryRequest(res, route, providerOptions, parsed, log14, options = {}) {
|
|
8123
8150
|
const sdkParams = applyClaudeCodeOAuthIdentity(route, translateRequest(parsed, {
|
|
8124
8151
|
...options.requestOptions,
|
|
8125
8152
|
maxTools: maxToolsForNpm(route.npm)
|
|
8126
8153
|
}));
|
|
8154
|
+
if (options.trace) {
|
|
8155
|
+
log14(`[gateway] sdk request: ${JSON.stringify(summarizeSdkRequestForTrace(sdkParams))}`);
|
|
8156
|
+
}
|
|
8127
8157
|
const effectiveProviderOptions = deepMergeProviderOptions(
|
|
8128
8158
|
providerOptions,
|
|
8129
8159
|
sdkParams.providerOptions
|
|
@@ -8230,7 +8260,8 @@ async function resolveAntigravityLaunchRoutes(opts) {
|
|
|
8230
8260
|
}
|
|
8231
8261
|
|
|
8232
8262
|
// src/antigravity/launch-cli.ts
|
|
8233
|
-
import { execFileSync as execFileSync2, execSync as execSync3
|
|
8263
|
+
import { execFileSync as execFileSync2, execSync as execSync3 } from "child_process";
|
|
8264
|
+
import spawn4 from "cross-spawn";
|
|
8234
8265
|
import { existsSync as existsSync6 } from "fs";
|
|
8235
8266
|
import { homedir as homedir6 } from "os";
|
|
8236
8267
|
import { join as join6 } from "path";
|
|
@@ -8290,8 +8321,7 @@ function launchAntigravityCli(env, extraArgs) {
|
|
|
8290
8321
|
}
|
|
8291
8322
|
const child = spawn4(binaryPath, extraArgs, {
|
|
8292
8323
|
stdio: "inherit",
|
|
8293
|
-
env
|
|
8294
|
-
shell: isWindows4
|
|
8324
|
+
env
|
|
8295
8325
|
});
|
|
8296
8326
|
const forward = (signal) => {
|
|
8297
8327
|
child.kill(signal);
|
|
@@ -8589,11 +8619,17 @@ function launchAntigravityApp(env, profileDir, gatewayUrl, extraArgs) {
|
|
|
8589
8619
|
}
|
|
8590
8620
|
function launchAntigravityIde(env, profileDir, gatewayUrl, extraArgs) {
|
|
8591
8621
|
return new Promise((resolve2) => {
|
|
8622
|
+
let settled = false;
|
|
8623
|
+
const settle = (code) => {
|
|
8624
|
+
if (settled) return;
|
|
8625
|
+
settled = true;
|
|
8626
|
+
resolve2(code);
|
|
8627
|
+
};
|
|
8592
8628
|
const binaryPath = findAntigravityIdeBinary();
|
|
8593
8629
|
if (!binaryPath) {
|
|
8594
8630
|
console.error("Antigravity IDE not found.");
|
|
8595
8631
|
console.error("Please make sure Antigravity IDE is installed.");
|
|
8596
|
-
|
|
8632
|
+
settle(127);
|
|
8597
8633
|
return;
|
|
8598
8634
|
}
|
|
8599
8635
|
prepareIdeProfile(profileDir, gatewayUrl);
|
|
@@ -8612,12 +8648,15 @@ function launchAntigravityIde(env, profileDir, gatewayUrl, extraArgs) {
|
|
|
8612
8648
|
detached: true,
|
|
8613
8649
|
env
|
|
8614
8650
|
});
|
|
8651
|
+
child.on("spawn", () => {
|
|
8652
|
+
settle(0);
|
|
8653
|
+
});
|
|
8615
8654
|
child.on("exit", (code) => {
|
|
8616
|
-
|
|
8655
|
+
settle(code ?? 1);
|
|
8617
8656
|
});
|
|
8618
8657
|
child.on("error", (err) => {
|
|
8619
8658
|
console.error(`Failed to launch Antigravity IDE: ${err.message}`);
|
|
8620
|
-
|
|
8659
|
+
settle(1);
|
|
8621
8660
|
});
|
|
8622
8661
|
});
|
|
8623
8662
|
}
|
|
@@ -8809,12 +8848,20 @@ async function resolveAndBuildRoutes(provider, model, allProviders, prefs, opts)
|
|
|
8809
8848
|
}
|
|
8810
8849
|
return { routes: result.routes, apiKey: result.apiKey };
|
|
8811
8850
|
}
|
|
8812
|
-
function waitForShutdown() {
|
|
8851
|
+
function waitForShutdown(input = process.stdin, platform = process.platform) {
|
|
8813
8852
|
return new Promise((resolve2) => {
|
|
8853
|
+
const captureWindowsCtrlC = platform === "win32" && input.isTTY;
|
|
8854
|
+
const wasRaw = input.isRaw;
|
|
8855
|
+
const wasPaused = input.isPaused();
|
|
8814
8856
|
const cleanup = () => {
|
|
8815
8857
|
process.removeListener("SIGINT", onSigint);
|
|
8816
8858
|
process.removeListener("SIGTERM", onSigterm);
|
|
8817
8859
|
process.removeListener("SIGHUP", onSighup);
|
|
8860
|
+
if (captureWindowsCtrlC) {
|
|
8861
|
+
input.removeListener("data", onInput);
|
|
8862
|
+
input.setRawMode(wasRaw);
|
|
8863
|
+
if (wasPaused) input.pause();
|
|
8864
|
+
}
|
|
8818
8865
|
};
|
|
8819
8866
|
const onSigint = () => {
|
|
8820
8867
|
cleanup();
|
|
@@ -8828,9 +8875,18 @@ function waitForShutdown() {
|
|
|
8828
8875
|
cleanup();
|
|
8829
8876
|
resolve2("sighup");
|
|
8830
8877
|
};
|
|
8878
|
+
const onInput = (chunk) => {
|
|
8879
|
+
const receivedCtrlC = typeof chunk === "string" ? chunk.includes("") : chunk.includes(3);
|
|
8880
|
+
if (receivedCtrlC) onSigint();
|
|
8881
|
+
};
|
|
8831
8882
|
process.once("SIGINT", onSigint);
|
|
8832
8883
|
process.once("SIGTERM", onSigterm);
|
|
8833
8884
|
process.once("SIGHUP", onSighup);
|
|
8885
|
+
if (captureWindowsCtrlC) {
|
|
8886
|
+
input.on("data", onInput);
|
|
8887
|
+
input.setRawMode(true);
|
|
8888
|
+
input.resume();
|
|
8889
|
+
}
|
|
8834
8890
|
});
|
|
8835
8891
|
}
|
|
8836
8892
|
async function runAntigravityCommand(intro, tracePrefix, trace, boot, launch, opts = {}) {
|
|
@@ -8864,14 +8920,8 @@ async function runAntigravityCommand(intro, tracePrefix, trace, boot, launch, op
|
|
|
8864
8920
|
lastAntigravityProvider: provider.id,
|
|
8865
8921
|
lastAntigravityModel: model.id
|
|
8866
8922
|
});
|
|
8867
|
-
const traceLogPath =
|
|
8868
|
-
const logFn =
|
|
8869
|
-
try {
|
|
8870
|
-
appendFileSync2(traceLogPath, `${msg}
|
|
8871
|
-
`);
|
|
8872
|
-
} catch {
|
|
8873
|
-
}
|
|
8874
|
-
} : void 0;
|
|
8923
|
+
const traceLogPath = trace ? getAntigravityDebugLogPath(tracePrefix) : void 0;
|
|
8924
|
+
const logFn = traceLogPath ? makeTraceLogger(traceLogPath) : void 0;
|
|
8875
8925
|
let gatewayHandle;
|
|
8876
8926
|
try {
|
|
8877
8927
|
gatewayHandle = await startCloudCodeGateway(routeResult.routes, { trace, logFn });
|
|
@@ -8881,7 +8931,7 @@ async function runAntigravityCommand(intro, tracePrefix, trace, boot, launch, op
|
|
|
8881
8931
|
}
|
|
8882
8932
|
p11.log.info(`Cloud Code gateway on ${pc9.cyan(`127.0.0.1:${gatewayHandle.port}`)}`);
|
|
8883
8933
|
p11.log.success(`Active model: ${formatCodexModelLabel(model)} ${pc9.dim("via")} ${provider.name}`);
|
|
8884
|
-
if (
|
|
8934
|
+
if (traceLogPath) p11.log.info(`Gateway trace \u2192 ${pc9.dim(traceLogPath)}`);
|
|
8885
8935
|
relayOutro("Launching", `${formatCodexModelLabel(model)} (${provider.name})`);
|
|
8886
8936
|
try {
|
|
8887
8937
|
const cleanEnv = buildAntigravityChildEnv(gatewayHandle.url);
|
|
@@ -12611,7 +12661,7 @@ ${pc12.bold("Usage:")}
|
|
|
12611
12661
|
${pc12.bold("Relay options:")}
|
|
12612
12662
|
--provider <id> Use a specific provider (skip picker)
|
|
12613
12663
|
--model <id> Use a specific model (skip picker)
|
|
12614
|
-
--trace Write debug log to
|
|
12664
|
+
--trace Write debug log to ~/.relay-ai/logs/antigravity-agy-debug.log
|
|
12615
12665
|
-h, --help Show this help
|
|
12616
12666
|
-v, --version Show version
|
|
12617
12667
|
|
|
@@ -12637,7 +12687,7 @@ ${pc12.bold("Usage:")}
|
|
|
12637
12687
|
${pc12.bold("Relay options:")}
|
|
12638
12688
|
--provider <id> Use a specific provider (skip picker)
|
|
12639
12689
|
--model <id> Use a specific model (skip picker)
|
|
12640
|
-
--trace Write debug log to
|
|
12690
|
+
--trace Write debug log to ~/.relay-ai/logs/antigravity-ide-debug.log
|
|
12641
12691
|
-h, --help Show this help
|
|
12642
12692
|
-v, --version Show version
|
|
12643
12693
|
|
|
@@ -12665,7 +12715,7 @@ ${pc12.bold("Usage:")}
|
|
|
12665
12715
|
${pc12.bold("Relay options:")}
|
|
12666
12716
|
--provider <id> Use a specific provider (skip picker)
|
|
12667
12717
|
--model <id> Use a specific model (skip picker)
|
|
12668
|
-
--trace Write debug log to
|
|
12718
|
+
--trace Write debug log to ~/.relay-ai/logs/antigravity-app-debug.log
|
|
12669
12719
|
-h, --help Show this help
|
|
12670
12720
|
-v, --version Show version
|
|
12671
12721
|
|
|
@@ -13393,7 +13443,7 @@ Options:
|
|
|
13393
13443
|
--trace Write debug logs under ~/.relay-ai/logs/`);
|
|
13394
13444
|
return 0;
|
|
13395
13445
|
}
|
|
13396
|
-
const { runUiCommand } = await import("./ui-command-
|
|
13446
|
+
const { runUiCommand } = await import("./ui-command-26QQUWTQ.js");
|
|
13397
13447
|
return runUiCommand({ trace: parsed.trace, serverMode: parsed.uiServerMode });
|
|
13398
13448
|
}
|
|
13399
13449
|
if (parsed.command === "models") {
|
|
@@ -13534,15 +13584,20 @@ function isCliEntryPoint() {
|
|
|
13534
13584
|
}
|
|
13535
13585
|
if (isCliEntryPoint()) {
|
|
13536
13586
|
main().then((exitCode) => {
|
|
13537
|
-
|
|
13587
|
+
gracefulExit(exitCode);
|
|
13538
13588
|
}).catch((err) => {
|
|
13539
13589
|
if (err === /* @__PURE__ */ Symbol.for("clack:cancel")) {
|
|
13540
|
-
|
|
13590
|
+
gracefulExit(0);
|
|
13591
|
+
return;
|
|
13541
13592
|
}
|
|
13542
13593
|
console.error(pc12.red("\nUnexpected error:"), err);
|
|
13543
|
-
|
|
13594
|
+
gracefulExit(1);
|
|
13544
13595
|
});
|
|
13545
13596
|
}
|
|
13597
|
+
function gracefulExit(code) {
|
|
13598
|
+
process.exitCode = code;
|
|
13599
|
+
setTimeout(() => process.exit(code), 500).unref();
|
|
13600
|
+
}
|
|
13546
13601
|
export {
|
|
13547
13602
|
antigravityAppHelpText,
|
|
13548
13603
|
antigravityCliHelpText,
|