@jacobbd/relay-ai 0.7.2 → 0.7.4

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
@@ -14,6 +14,8 @@ import {
14
14
  addOpencodeCloudFromApiKey,
15
15
  addProviderFromTemplate,
16
16
  aliasModelId,
17
+ anthropicMessagesEndpoint,
18
+ anthropicModelsEndpoint,
17
19
  appendCodexBodyDump,
18
20
  authenticateProvider,
19
21
  buildAntigravityChildEnv,
@@ -45,6 +47,7 @@ import {
45
47
  effectiveProviderBaseUrl,
46
48
  effortProviderOptions,
47
49
  encodeToolUseId,
50
+ estimateAnthropicInputTokens,
48
51
  evaluateAgySwitchCompatibility,
49
52
  extractApiKey,
50
53
  favoriteProviderDisplayName,
@@ -174,7 +177,7 @@ import {
174
177
  validateCustomEndpointUrl,
175
178
  writeSecureLogLine,
176
179
  zenRegistryStub
177
- } from "./chunk-LNQ46VW7.js";
180
+ } from "./chunk-EUY2MVOS.js";
178
181
  import {
179
182
  filterTemplates,
180
183
  init_provider_templates,
@@ -11464,54 +11467,6 @@ import * as https from "https";
11464
11467
  import * as net from "net";
11465
11468
  import { randomBytes as randomBytes2, timingSafeEqual } from "crypto";
11466
11469
  import { URL as URL2 } from "url";
11467
-
11468
- // src/anthropic-endpoints.ts
11469
- var MESSAGE_PATH = "/v1/messages";
11470
- var COUNT_TOKENS_PATH = "/v1/messages/count_tokens";
11471
- var MODELS_PATH = "/v1/models";
11472
- function anthropicModelsEndpoint(url) {
11473
- if (!url) return null;
11474
- try {
11475
- const pathname = new URL(url, "http://relay.local").pathname;
11476
- if (pathname === MODELS_PATH || pathname === `${MODELS_PATH}/`) return "list";
11477
- if (pathname.startsWith(`${MODELS_PATH}/`)) {
11478
- const id = decodeURIComponent(pathname.slice(MODELS_PATH.length + 1));
11479
- if (id) return { id };
11480
- }
11481
- } catch {
11482
- }
11483
- return null;
11484
- }
11485
- function anthropicMessagesEndpoint(url) {
11486
- if (!url) return null;
11487
- try {
11488
- const pathname = new URL(url, "http://relay.local").pathname;
11489
- if (pathname === MESSAGE_PATH) return "messages";
11490
- if (pathname === COUNT_TOKENS_PATH) return "count_tokens";
11491
- } catch {
11492
- }
11493
- return null;
11494
- }
11495
- var NON_CONTEXT_FIELDS = /* @__PURE__ */ new Set([
11496
- "model",
11497
- "stream",
11498
- "max_tokens",
11499
- "temperature",
11500
- "top_p",
11501
- "top_k",
11502
- "stop_sequences",
11503
- "metadata"
11504
- ]);
11505
- function estimateAnthropicInputTokens(body) {
11506
- const contextBody = Object.fromEntries(
11507
- Object.entries(body).filter(([key]) => !NON_CONTEXT_FIELDS.has(key))
11508
- );
11509
- const serialized = JSON.stringify(contextBody);
11510
- if (!serialized || serialized === "{}") return 0;
11511
- return Math.max(1, Math.ceil(Buffer.byteLength(serialized, "utf8") / 4));
11512
- }
11513
-
11514
- // src/http-proxy/server.ts
11515
11470
  var ANTHROPIC_HOST = RELAY_SENTINEL_HOST;
11516
11471
  var MAX_BODY_BYTES = 50 * 1024 * 1024;
11517
11472
  var PROXY_USERNAME = "relay-ai";
@@ -13438,7 +13393,7 @@ Options:
13438
13393
  --trace Write debug logs under ~/.relay-ai/logs/`);
13439
13394
  return 0;
13440
13395
  }
13441
- const { runUiCommand } = await import("./ui-command-5VEFZ5GM.js");
13396
+ const { runUiCommand } = await import("./ui-command-CF3IEIZP.js");
13442
13397
  return runUiCommand({ trace: parsed.trace, serverMode: parsed.uiServerMode });
13443
13398
  }
13444
13399
  if (parsed.command === "models") {
@@ -13579,15 +13534,20 @@ function isCliEntryPoint() {
13579
13534
  }
13580
13535
  if (isCliEntryPoint()) {
13581
13536
  main().then((exitCode) => {
13582
- process.exit(exitCode);
13537
+ gracefulExit(exitCode);
13583
13538
  }).catch((err) => {
13584
13539
  if (err === /* @__PURE__ */ Symbol.for("clack:cancel")) {
13585
- process.exit(0);
13540
+ gracefulExit(0);
13541
+ return;
13586
13542
  }
13587
13543
  console.error(pc12.red("\nUnexpected error:"), err);
13588
- process.exit(1);
13544
+ gracefulExit(1);
13589
13545
  });
13590
13546
  }
13547
+ function gracefulExit(code) {
13548
+ process.exitCode = code;
13549
+ setTimeout(() => process.exit(code), 500).unref();
13550
+ }
13591
13551
  export {
13592
13552
  antigravityAppHelpText,
13593
13553
  antigravityCliHelpText,