proxitor 0.9.0-beta.9 → 0.9.1

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.mjs CHANGED
@@ -19924,12 +19924,12 @@ function displayModelInfo(model, options) {
19924
19924
  log.info(` ${desc}`);
19925
19925
  }
19926
19926
  log.info(` Context: ${formatContextLength(model.context_length)} tokens`);
19927
- if (model.top_provider?.max_completion_tokens) log.info(` Max output: ${formatContextLength(model.top_provider.max_completion_tokens)} tokens`);
19927
+ if (model.top_provider.max_completion_tokens) log.info(` Max output: ${formatContextLength(model.top_provider.max_completion_tokens)} tokens`);
19928
19928
  log.info(` Pricing: ${formatPricing(model.pricing.prompt, model.pricing.completion)}`);
19929
19929
  logNonZeroPrice("Cache read", model.pricing.input_cache_read);
19930
19930
  logNonZeroPrice("Cache write", model.pricing.input_cache_write);
19931
- if (model.architecture?.modality) log.info(` Modality: ${model.architecture.modality}`);
19932
- if (showParameters && model.supported_parameters?.length) log.info(` Parameters: ${model.supported_parameters.join(", ")}`);
19931
+ if (model.architecture.modality) log.info(` Modality: ${model.architecture.modality}`);
19932
+ if (showParameters && model.supported_parameters.length) log.info(` Parameters: ${model.supported_parameters.join(", ")}`);
19933
19933
  }
19934
19934
  function formatPricing(prompt, completion) {
19935
19935
  return `${formatPrice(prompt)} / ${formatPrice(completion)}`;
@@ -20168,19 +20168,20 @@ async function askBaseUrl(current) {
20168
20168
  if (isCancel(url)) return null;
20169
20169
  return url.trim() || DEFAULTS.openrouterBaseUrl;
20170
20170
  }
20171
+ const AUTH_OPTIONS = [{
20172
+ value: "bearer",
20173
+ label: "Bearer token",
20174
+ hint: "Standard OpenRouter"
20175
+ }, {
20176
+ value: "oauth",
20177
+ label: "OAuth token",
20178
+ hint: "Custom proxy providers"
20179
+ }];
20171
20180
  async function askAuthType(current) {
20172
20181
  const authType = await select({
20173
20182
  message: "Authentication type",
20174
20183
  initialValue: current,
20175
- options: [{
20176
- value: "bearer",
20177
- label: "Bearer token",
20178
- hint: "Standard OpenRouter"
20179
- }, {
20180
- value: "oauth",
20181
- label: "OAuth token",
20182
- hint: "Custom proxy providers"
20183
- }]
20184
+ options: AUTH_OPTIONS
20184
20185
  });
20185
20186
  if (isCancel(authType)) return null;
20186
20187
  return authType;
@@ -20477,7 +20478,7 @@ async function collectCache(override) {
20477
20478
  * Returns true if the override was saved.
20478
20479
  */
20479
20480
  async function confirmAndSave(configPath, modelKey, override, _client) {
20480
- while (true) {
20481
+ for (;;) {
20481
20482
  log.info(`Proposed override:\n ${modelKey}:\n ${formatOverrideYaml(override)}`);
20482
20483
  const action = await select({
20483
20484
  message: "What next?",
@@ -20688,7 +20689,7 @@ async function editOverrideCommand(client, configPath) {
20688
20689
  const modelKey = selected;
20689
20690
  let current = overrides[modelKey] ?? {};
20690
20691
  showCurrentConfig(modelKey, current);
20691
- while (true) {
20692
+ for (;;) {
20692
20693
  const field = await select({
20693
20694
  message: "Edit which field?",
20694
20695
  options: [
@@ -21140,6 +21141,10 @@ function buildYaml(apiKey, port, host, baseUrl, authType, existingRaw) {
21140
21141
  if (authType !== DEFAULTS.authType) config.authType = authType;
21141
21142
  return (0, import_dist.stringify)(config);
21142
21143
  }
21144
+ /** Preview header — URL and auth are shown even when `buildYaml` omits defaults. */
21145
+ function formatPreviewHeader(baseUrl, authType) {
21146
+ return `Base URL: ${baseUrl}\nAuth: ${AUTH_OPTIONS.find((o) => o.value === authType)?.label ?? authType}`;
21147
+ }
21143
21148
  async function askSaveLocation(existingPath) {
21144
21149
  const options = getSaveLocationOptions(existingPath);
21145
21150
  const location = await select({
@@ -21231,7 +21236,7 @@ async function runWizard(opts = {}) {
21231
21236
  log.step(`Step ${TOTAL_STEPS}/${TOTAL_STEPS}: Save location`);
21232
21237
  const location = expectValue(await askSaveLocation(existingPath ?? opts.configPath));
21233
21238
  const yaml = buildYaml(answers.apiKey, answers.port, answers.host, answers.baseUrl, answers.authType, existingRaw);
21234
- note(yaml, "Preview");
21239
+ note(`${formatPreviewHeader(answers.baseUrl, answers.authType)}\n${yaml}`, "Preview");
21235
21240
  const save = await confirm({
21236
21241
  message: "Save this configuration?",
21237
21242
  initialValue: true
@@ -21371,7 +21376,7 @@ async function sessionRoutingCommand(opts) {
21371
21376
  //#region src/commands/config.ts
21372
21377
  async function runConfigMenu(client) {
21373
21378
  intro("Proxitor Config Manager");
21374
- while (true) {
21379
+ for (;;) {
21375
21380
  const action = await select({
21376
21381
  message: "What would you like to do?",
21377
21382
  options: [
@@ -21476,7 +21481,7 @@ async function runConfigMenu(client) {
21476
21481
  }
21477
21482
  //#endregion
21478
21483
  //#region src/version.ts
21479
- const version = "0.9.0-beta.9";
21484
+ const version = "0.9.1";
21480
21485
  //#endregion
21481
21486
  //#region src/commands/doctor.ts
21482
21487
  const DEFAULT_TIMEOUT_MS = 3e3;
@@ -21642,7 +21647,7 @@ function checkVersion() {
21642
21647
  return {
21643
21648
  name: "version",
21644
21649
  status: "ok",
21645
- current: version
21650
+ value: version
21646
21651
  };
21647
21652
  }
21648
21653
  const STATUS_GLYPHS = {
@@ -21714,7 +21719,7 @@ async function doctorCommand(opts = {}) {
21714
21719
  return exitCode;
21715
21720
  }
21716
21721
  //#endregion
21717
- //#region node_modules/.pnpm/@hono+node-server@2.0.4_hono@4.12.23/node_modules/@hono/node-server/dist/index.mjs
21722
+ //#region node_modules/.pnpm/@hono+node-server@2.0.4_hono@4.12.25/node_modules/@hono/node-server/dist/index.mjs
21718
21723
  var RequestError = class extends Error {
21719
21724
  constructor(message, options) {
21720
21725
  super(message, options);
@@ -22637,7 +22642,7 @@ const serve = (options, listeningListener) => {
22637
22642
  return server;
22638
22643
  };
22639
22644
  //#endregion
22640
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/compose.js
22645
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/compose.js
22641
22646
  var compose = (middleware, onError, onNotFound) => {
22642
22647
  return (context, next) => {
22643
22648
  let index = -1;
@@ -22668,10 +22673,10 @@ var compose = (middleware, onError, onNotFound) => {
22668
22673
  };
22669
22674
  };
22670
22675
  //#endregion
22671
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/request/constants.js
22676
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/request/constants.js
22672
22677
  var GET_MATCH_RESULT = /* @__PURE__ */ Symbol();
22673
22678
  //#endregion
22674
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/utils/body.js
22679
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/utils/body.js
22675
22680
  var parseBody$1 = async (request, options = /* @__PURE__ */ Object.create(null)) => {
22676
22681
  const { all = false, dot = false } = options;
22677
22682
  const contentType = (request instanceof HonoRequest ? request.raw.headers : request.headers).get("Content-Type");
@@ -22719,7 +22724,7 @@ var handleParsingNestedValues = (form, key, value) => {
22719
22724
  });
22720
22725
  };
22721
22726
  //#endregion
22722
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/utils/url.js
22727
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/utils/url.js
22723
22728
  var splitPath = (path) => {
22724
22729
  const paths = path.split("/");
22725
22730
  if (paths[0] === "") paths.shift();
@@ -22883,7 +22888,7 @@ var getQueryParams = (url, key) => {
22883
22888
  };
22884
22889
  var decodeURIComponent_ = decodeURIComponent;
22885
22890
  //#endregion
22886
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/request.js
22891
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/request.js
22887
22892
  var tryDecodeURIComponent = (str) => tryDecode(str, decodeURIComponent_);
22888
22893
  var HonoRequest = class {
22889
22894
  /**
@@ -23155,7 +23160,7 @@ var HonoRequest = class {
23155
23160
  }
23156
23161
  };
23157
23162
  //#endregion
23158
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/utils/html.js
23163
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/utils/html.js
23159
23164
  var HtmlEscapedCallbackPhase = {
23160
23165
  Stringify: 1,
23161
23166
  BeforeStream: 2,
@@ -23185,7 +23190,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
23185
23190
  else return resStr;
23186
23191
  };
23187
23192
  //#endregion
23188
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/context.js
23193
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/context.js
23189
23194
  var TEXT_PLAIN = "text/plain; charset=UTF-8";
23190
23195
  var setDefaultContentType = (contentType, headers) => {
23191
23196
  return {
@@ -23546,7 +23551,7 @@ var Context = class {
23546
23551
  };
23547
23552
  };
23548
23553
  //#endregion
23549
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/router.js
23554
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/router.js
23550
23555
  var METHODS = [
23551
23556
  "get",
23552
23557
  "post",
@@ -23558,10 +23563,10 @@ var METHODS = [
23558
23563
  var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
23559
23564
  var UnsupportedPathError = class extends Error {};
23560
23565
  //#endregion
23561
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/utils/constants.js
23566
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/utils/constants.js
23562
23567
  var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
23563
23568
  //#endregion
23564
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/hono-base.js
23569
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/hono-base.js
23565
23570
  var notFoundHandler = (c) => {
23566
23571
  return c.text("404 Not Found", 404);
23567
23572
  };
@@ -23895,7 +23900,7 @@ var Hono$1 = class _Hono {
23895
23900
  };
23896
23901
  };
23897
23902
  //#endregion
23898
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/router/reg-exp-router/matcher.js
23903
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/router/reg-exp-router/matcher.js
23899
23904
  var emptyParam = [];
23900
23905
  function match(method, path) {
23901
23906
  const matchers = this.buildAllMatchers();
@@ -23912,7 +23917,7 @@ function match(method, path) {
23912
23917
  return match2(method, path);
23913
23918
  }
23914
23919
  //#endregion
23915
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/router/reg-exp-router/node.js
23920
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/router/reg-exp-router/node.js
23916
23921
  var LABEL_REG_EXP_STR = "[^/]+";
23917
23922
  var ONLY_WILDCARD_REG_EXP_STR = ".*";
23918
23923
  var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
@@ -23991,7 +23996,7 @@ var Node$1 = class _Node {
23991
23996
  }
23992
23997
  };
23993
23998
  //#endregion
23994
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/router/reg-exp-router/trie.js
23999
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/router/reg-exp-router/trie.js
23995
24000
  var Trie = class {
23996
24001
  #context = { varIndex: 0 };
23997
24002
  #root = new Node$1();
@@ -24049,7 +24054,7 @@ var Trie = class {
24049
24054
  }
24050
24055
  };
24051
24056
  //#endregion
24052
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/router/reg-exp-router/router.js
24057
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/router/reg-exp-router/router.js
24053
24058
  var nullMatcher = [
24054
24059
  /^$/,
24055
24060
  [],
@@ -24180,7 +24185,7 @@ var RegExpRouter = class {
24180
24185
  }
24181
24186
  };
24182
24187
  //#endregion
24183
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/router/smart-router/router.js
24188
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/router/smart-router/router.js
24184
24189
  var SmartRouter = class {
24185
24190
  name = "SmartRouter";
24186
24191
  #routers = [];
@@ -24227,7 +24232,7 @@ var SmartRouter = class {
24227
24232
  }
24228
24233
  };
24229
24234
  //#endregion
24230
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/router/trie-router/node.js
24235
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/router/trie-router/node.js
24231
24236
  var emptyParams = /* @__PURE__ */ Object.create(null);
24232
24237
  var hasChildren = (children) => {
24233
24238
  for (const _ in children) return true;
@@ -24380,7 +24385,7 @@ var Node = class _Node {
24380
24385
  }
24381
24386
  };
24382
24387
  //#endregion
24383
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/router/trie-router/router.js
24388
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/router/trie-router/router.js
24384
24389
  var TrieRouter = class {
24385
24390
  name = "TrieRouter";
24386
24391
  #node;
@@ -24400,7 +24405,7 @@ var TrieRouter = class {
24400
24405
  }
24401
24406
  };
24402
24407
  //#endregion
24403
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/hono.js
24408
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/hono.js
24404
24409
  var Hono = class extends Hono$1 {
24405
24410
  /**
24406
24411
  * Creates an instance of the Hono class.
@@ -24413,7 +24418,7 @@ var Hono = class extends Hono$1 {
24413
24418
  }
24414
24419
  };
24415
24420
  //#endregion
24416
- //#region node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/helper/factory/index.js
24421
+ //#region node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/helper/factory/index.js
24417
24422
  var createMiddleware = (middleware) => middleware;
24418
24423
  //#endregion
24419
24424
  //#region src/proxy/headers.ts
@@ -24742,7 +24747,8 @@ const INJECT_PATHS = new Set(Object.keys(ENDPOINT_MAP));
24742
24747
  /** Endpoints that are natively Anthropic (cache_control is always safe regardless of model). */
24743
24748
  const ANTHROPIC_NATIVE_ENDPOINTS = new Set(["messages", "responses"]);
24744
24749
  function classifyEndpoint(pathname) {
24745
- return ENDPOINT_MAP[pathname] ?? "other";
24750
+ const queryIndex = pathname.indexOf("?");
24751
+ return ENDPOINT_MAP[queryIndex === -1 ? pathname : pathname.slice(0, queryIndex)] ?? "other";
24746
24752
  }
24747
24753
  function buildUpstreamUrl(pathname, config) {
24748
24754
  return `${config.openrouterBaseUrl}${pathname}`;
@@ -24782,8 +24788,8 @@ const injectCacheControl = createMiddleware(async (c, next) => {
24782
24788
  await next();
24783
24789
  return;
24784
24790
  }
24785
- if (shouldInjectCacheControl(resolved.cacheControl, c.var.modelName, c.var.path)) {
24786
- const isAnthropic = isAnthropicEndpoint(c.var.modelName, c.var.path);
24791
+ if (shouldInjectCacheControl(resolved.cacheControl, c.var.modelName, c.req.path)) {
24792
+ const isAnthropic = isAnthropicEndpoint(c.var.modelName, c.req.path);
24787
24793
  parsedBody.cache_control = buildCacheControl(parsedBody.cache_control, resolved.cacheControlTtl, isAnthropic);
24788
24794
  c.set("bodyMutated", true);
24789
24795
  }
@@ -24861,7 +24867,7 @@ function deriveSessionId(incomingHeaders, parsedBody, path, mode) {
24861
24867
  //#region src/proxy/middleware/inject-session-id.ts
24862
24868
  const injectSessionId = createMiddleware(async (c, next) => {
24863
24869
  const mode = c.var.resolvedConfig.sessionId;
24864
- const sessionId = deriveSessionId(c.req.raw.headers, c.var.parsedBody, c.var.path, mode);
24870
+ const sessionId = deriveSessionId(c.req.raw.headers, c.var.parsedBody, c.req.path, mode);
24865
24871
  if (sessionId) c.set("effectiveSessionId", sessionId);
24866
24872
  await next();
24867
24873
  });
@@ -24889,16 +24895,15 @@ const parseBody = createMiddleware(async (c, next) => {
24889
24895
  });
24890
24896
  //#endregion
24891
24897
  //#region src/proxy/middleware/read-body.ts
24898
+ const BODY_LIMIT_MULTIPLIERS = {
24899
+ kb: 1024,
24900
+ mb: 1024 ** 2,
24901
+ gb: 1024 ** 3
24902
+ };
24892
24903
  function parseBodyLimit(limit) {
24893
24904
  const match = limit.match(/^(\d+)\s*(kb|mb|gb)$/i);
24894
24905
  if (!match) return Number.MAX_SAFE_INTEGER;
24895
- const n = parseInt(match[1], 10);
24896
- switch (match[2].toLowerCase()) {
24897
- case "kb": return n * 1024;
24898
- case "mb": return n * 1024 * 1024;
24899
- case "gb": return n * 1024 * 1024 * 1024;
24900
- default: return Number.MAX_SAFE_INTEGER;
24901
- }
24906
+ return parseInt(match[1], 10) * BODY_LIMIT_MULTIPLIERS[match[2].toLowerCase()];
24902
24907
  }
24903
24908
  const readBody = createMiddleware(async (c, next) => {
24904
24909
  const method = c.var.method;
@@ -25273,7 +25278,7 @@ const doctorCli = (0, import_cjs.command)({
25273
25278
  timeout: (0, import_cjs.option)({
25274
25279
  long: "timeout",
25275
25280
  short: "t",
25276
- type: import_cjs.string,
25281
+ type: (0, import_cjs.optional)(import_cjs.string),
25277
25282
  description: "Network check timeout in milliseconds"
25278
25283
  })
25279
25284
  },