blun-king-cli 9.1.651 → 9.1.652

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/blun.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- // BLUN_BUILD_INPUT_SHA256:a5e52631e1ab89d435768bac2bb6a5b92e2cc3eb1d0fd3c664d2a301a71a8c0c
2
+ // BLUN_BUILD_INPUT_SHA256:eb9ff5c11e4d39258f3ee406617ae870eb89e80c7311e5c8e6c81b578c4432a1
3
3
  import { fileURLToPath as __cjsShimFileURLToPath } from 'node:url';
4
4
  import { dirname as __cjsShimDirname } from 'node:path';
5
5
  const __filename = __cjsShimFileURLToPath(import.meta.url);
6
6
  const __dirname = __cjsShimDirname(__filename);
7
7
  import { createRequire } from "node:module";
8
8
  import crypto$1, { createHash, randomBytes, randomInt, randomUUID, timingSafeEqual } from "node:crypto";
9
- import * as fs$17 from "node:fs";
9
+ import * as fs$16 from "node:fs";
10
10
  import Vt, { appendFileSync, chmodSync, closeSync, constants, copyFileSync, createReadStream, createWriteStream, existsSync, fstatSync, fsyncSync, linkSync, lstatSync, mkdirSync, openSync, promises, readFileSync, readSync, readdirSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
11
11
  import * as path$16 from "node:path";
12
12
  import path, { basename, dirname, extname, isAbsolute, join, normalize, parse, posix, relative, resolve, sep, win32 } from "node:path";
@@ -21,7 +21,7 @@ import { TextDecoder as TextDecoder$1, promisify, stripVTControlCharacters } fro
21
21
  import { performance as performance$1 } from "node:perf_hooks";
22
22
  import { fileURLToPath, pathToFileURL } from "node:url";
23
23
  import { AsyncLocalStorage } from "node:async_hooks";
24
- import fs, { access, appendFile, chmod, copyFile, cp, link, lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rename, rm, rmdir, stat, unlink, writeFile } from "node:fs/promises";
24
+ import jn, { access, appendFile, chmod, copyFile, cp, link, lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rename, rm, rmdir, stat, unlink, writeFile } from "node:fs/promises";
25
25
  import * as nodeOs from "node:os";
26
26
  import os, { arch, homedir, hostname, networkInterfaces, platform, release, tmpdir, type, userInfo } from "node:os";
27
27
  import Kr, { EventEmitter as EventEmitter$1 } from "events";
@@ -23577,11 +23577,11 @@ var init_blun_files = __esmMin((() => {
23577
23577
  signal?.throwIfAborted();
23578
23578
  let file;
23579
23579
  if (typeof input === "string") {
23580
- if (!fs$17.existsSync(input)) throw new ChatProviderError(`Video file not found: ${input}`);
23580
+ if (!fs$16.existsSync(input)) throw new ChatProviderError(`Video file not found: ${input}`);
23581
23581
  const filename = path$16.basename(input);
23582
23582
  const mimeType = guessMimeTypeFromExt(filename);
23583
23583
  if (mimeType === void 0 || !mimeType.startsWith("video/")) throw new ChatProviderError(`BlunFiles.uploadVideo: file extension does not indicate a video type: ${filename}`);
23584
- const data = await fs$17.promises.readFile(input, { signal });
23584
+ const data = await fs$16.promises.readFile(input, { signal });
23585
23585
  file = new File$1([new Blob$1([new Uint8Array(data)], { type: mimeType })], filename, { type: mimeType });
23586
23586
  } else {
23587
23587
  if (!input.mimeType.startsWith("video/")) throw new ChatProviderError(`Expected a video mime type, got ${input.mimeType}`);
@@ -31711,7 +31711,7 @@ async function syncDir(dirPath) {
31711
31711
  */
31712
31712
  function syncFd(fd) {
31713
31713
  return new Promise((resolve, reject) => {
31714
- fs$17.fsync(fd, (err) => {
31714
+ fs$16.fsync(fd, (err) => {
31715
31715
  if (err) {
31716
31716
  reject(err);
31717
31717
  return;
@@ -37563,8 +37563,8 @@ function parseSkillText(options) {
37563
37563
  if (!isRecord$13(frontmatter)) throw new SkillParseError(`Frontmatter in ${options.skillMdPath} must be a mapping at the top level`);
37564
37564
  const metadata = normalizeMetadata(frontmatter);
37565
37565
  if (!isSupportedSkillType(metadata.type)) throw new UnsupportedSkillTypeError(metadata.type ?? String(frontmatter["type"]));
37566
- const name = nonEmptyString$5(metadata.name);
37567
- const description = nonEmptyString$5(metadata.description);
37566
+ const name = nonEmptyString$6(metadata.name);
37567
+ const description = nonEmptyString$6(metadata.description);
37568
37568
  if (isDirectorySkill && (name === void 0 || description === void 0)) throw new SkillParseError(`Missing required frontmatter field ${name === void 0 ? "\"name\"" : "\"description\""} in ${options.skillMdPath}`);
37569
37569
  const skillPath = posix$2.resolve(options.skillMdPath);
37570
37570
  const content = parsed.body.trim();
@@ -37624,11 +37624,11 @@ function normalizeMetadata(raw) {
37624
37624
  const key = METADATA_ALIASES[rawKey] ?? rawKey;
37625
37625
  out[key] = value;
37626
37626
  }
37627
- const type = nonEmptyString$5(out["type"]);
37627
+ const type = nonEmptyString$6(out["type"]);
37628
37628
  if (type !== void 0) out["type"] = type;
37629
- const name = nonEmptyString$5(out["name"]);
37629
+ const name = nonEmptyString$6(out["name"]);
37630
37630
  if (name !== void 0) out["name"] = name;
37631
- const description = nonEmptyString$5(out["description"]);
37631
+ const description = nonEmptyString$6(out["description"]);
37632
37632
  if (description !== void 0) out["description"] = description;
37633
37633
  return out;
37634
37634
  }
@@ -37670,7 +37670,7 @@ function tokenizeArgs(raw) {
37670
37670
  if (hasContent) out.push(current);
37671
37671
  return out;
37672
37672
  }
37673
- function nonEmptyString$5(value) {
37673
+ function nonEmptyString$6(value) {
37674
37674
  return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
37675
37675
  }
37676
37676
  function isRecord$13(value) {
@@ -37724,12 +37724,12 @@ function parseCommandText(input) {
37724
37724
  const parsed = parseFrontmatter(text);
37725
37725
  const frontmatter = isRecord$12(parsed.data) ? parsed.data : {};
37726
37726
  const baseName = input.fallbackName ?? path.basename(commandPath).replace(/\.md$/i, "");
37727
- const name = nonEmptyString$4(frontmatter["name"]) ?? baseName;
37727
+ const name = nonEmptyString$5(frontmatter["name"]) ?? baseName;
37728
37728
  const body = parsed.body.trim();
37729
37729
  return {
37730
37730
  pluginId,
37731
37731
  name,
37732
- description: nonEmptyString$4(frontmatter["description"]) ?? descriptionFromBody(body),
37732
+ description: nonEmptyString$5(frontmatter["description"]) ?? descriptionFromBody(body),
37733
37733
  body,
37734
37734
  path: path.resolve(commandPath)
37735
37735
  };
@@ -37756,7 +37756,7 @@ function expandCommandArguments(body, args) {
37756
37756
  if (!body.includes("$ARGUMENTS") && args.length > 0) return `${replaced}\n\nARGUMENTS: ${args}`;
37757
37757
  return replaced;
37758
37758
  }
37759
- function nonEmptyString$4(value) {
37759
+ function nonEmptyString$5(value) {
37760
37760
  return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
37761
37761
  }
37762
37762
  function descriptionFromBody(body) {
@@ -43420,7 +43420,7 @@ var require_node_loaders = /* @__PURE__ */ __commonJSMin(((exports, module) => {
43420
43420
  };
43421
43421
  return _setPrototypeOf(o, p);
43422
43422
  }
43423
- var fs$16 = __require("fs");
43423
+ var fs$15 = __require("fs");
43424
43424
  var path$14 = __require("path");
43425
43425
  var Loader = require_loader();
43426
43426
  var PrecompiledLoader = require_precompiled_loader().PrecompiledLoader;
@@ -43444,7 +43444,7 @@ var require_node_loaders = /* @__PURE__ */ __commonJSMin(((exports, module) => {
43444
43444
  } catch (e) {
43445
43445
  throw new Error("watch requires chokidar to be installed");
43446
43446
  }
43447
- var paths = _this.searchPaths.filter(fs$16.existsSync);
43447
+ var paths = _this.searchPaths.filter(fs$15.existsSync);
43448
43448
  var watcher = chokidar.watch(paths);
43449
43449
  watcher.on("all", function(event, fullname) {
43450
43450
  fullname = path$14.resolve(fullname);
@@ -43463,7 +43463,7 @@ var require_node_loaders = /* @__PURE__ */ __commonJSMin(((exports, module) => {
43463
43463
  for (var i = 0; i < paths.length; i++) {
43464
43464
  var basePath = path$14.resolve(paths[i]);
43465
43465
  var p = path$14.resolve(paths[i], name);
43466
- if (p.indexOf(basePath) === 0 && fs$16.existsSync(p)) {
43466
+ if (p.indexOf(basePath) === 0 && fs$15.existsSync(p)) {
43467
43467
  fullpath = p;
43468
43468
  break;
43469
43469
  }
@@ -43471,7 +43471,7 @@ var require_node_loaders = /* @__PURE__ */ __commonJSMin(((exports, module) => {
43471
43471
  if (!fullpath) return null;
43472
43472
  this.pathsToNames[fullpath] = name;
43473
43473
  var source = {
43474
- src: fs$16.readFileSync(fullpath, "utf-8"),
43474
+ src: fs$15.readFileSync(fullpath, "utf-8"),
43475
43475
  path: fullpath,
43476
43476
  noCache: this.noCache
43477
43477
  };
@@ -43519,7 +43519,7 @@ var require_node_loaders = /* @__PURE__ */ __commonJSMin(((exports, module) => {
43519
43519
  }
43520
43520
  this.pathsToNames[fullpath] = name;
43521
43521
  var source = {
43522
- src: fs$16.readFileSync(fullpath, "utf-8"),
43522
+ src: fs$15.readFileSync(fullpath, "utf-8"),
43523
43523
  path: fullpath,
43524
43524
  noCache: this.noCache
43525
43525
  };
@@ -44263,7 +44263,7 @@ var require_precompile_global = /* @__PURE__ */ __commonJSMin(((exports, module)
44263
44263
  //#endregion
44264
44264
  //#region ../../node_modules/.pnpm/nunjucks@3.2.4_chokidar@4.0.3/node_modules/nunjucks/src/precompile.js
44265
44265
  var require_precompile = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44266
- var fs$15 = __require("fs");
44266
+ var fs$14 = __require("fs");
44267
44267
  var path$12 = __require("path");
44268
44268
  var _prettifyError = require_lib$7()._prettifyError;
44269
44269
  var compiler = require_compiler();
@@ -44288,27 +44288,27 @@ var require_precompile = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44288
44288
  var env = opts.env || new Environment([]);
44289
44289
  var wrapper = opts.wrapper || precompileGlobal;
44290
44290
  if (opts.isString) return precompileString(input, opts);
44291
- var pathStats = fs$15.existsSync(input) && fs$15.statSync(input);
44291
+ var pathStats = fs$14.existsSync(input) && fs$14.statSync(input);
44292
44292
  var precompiled = [];
44293
44293
  var templates = [];
44294
44294
  function addTemplates(dir) {
44295
- fs$15.readdirSync(dir).forEach(function(file) {
44295
+ fs$14.readdirSync(dir).forEach(function(file) {
44296
44296
  var filepath = path$12.join(dir, file);
44297
44297
  var subpath = filepath.substr(path$12.join(input, "/").length);
44298
- var stat = fs$15.statSync(filepath);
44298
+ var stat = fs$14.statSync(filepath);
44299
44299
  if (stat && stat.isDirectory()) {
44300
44300
  subpath += "/";
44301
44301
  if (!match(subpath, opts.exclude)) addTemplates(filepath);
44302
44302
  } else if (match(subpath, opts.include)) templates.push(filepath);
44303
44303
  });
44304
44304
  }
44305
- if (pathStats.isFile()) precompiled.push(_precompile(fs$15.readFileSync(input, "utf-8"), opts.name || input, env));
44305
+ if (pathStats.isFile()) precompiled.push(_precompile(fs$14.readFileSync(input, "utf-8"), opts.name || input, env));
44306
44306
  else if (pathStats.isDirectory()) {
44307
44307
  addTemplates(input);
44308
44308
  for (var i = 0; i < templates.length; i++) {
44309
44309
  var name = templates[i].replace(path$12.join(input, "/"), "");
44310
44310
  try {
44311
- precompiled.push(_precompile(fs$15.readFileSync(templates[i], "utf-8"), name, env));
44311
+ precompiled.push(_precompile(fs$14.readFileSync(templates[i], "utf-8"), name, env));
44312
44312
  } catch (e) {
44313
44313
  if (opts.force) console.error(e);
44314
44314
  else throw e;
@@ -58613,7 +58613,7 @@ var require_gifframe = /* @__PURE__ */ __commonJSMin(((exports) => {
58613
58613
  //#region ../../node_modules/.pnpm/gifwrap@0.10.1/node_modules/gifwrap/src/gifutil.js
58614
58614
  var require_gifutil = /* @__PURE__ */ __commonJSMin(((exports) => {
58615
58615
  /** @namespace GifUtil */
58616
- const fs$14 = __require("fs");
58616
+ const fs$13 = __require("fs");
58617
58617
  const ImageQ = require_image_q();
58618
58618
  const BitmapImage = require_bitmapimage();
58619
58619
  const { GifFrame } = require_gifframe();
@@ -58880,7 +58880,7 @@ var require_gifutil = /* @__PURE__ */ __commonJSMin(((exports) => {
58880
58880
  }
58881
58881
  function _readBinary(path) {
58882
58882
  return new Promise((resolve, reject) => {
58883
- fs$14.readFile(path, (err, buffer) => {
58883
+ fs$13.readFile(path, (err, buffer) => {
58884
58884
  if (err) return reject(err);
58885
58885
  return resolve(buffer);
58886
58886
  });
@@ -58888,7 +58888,7 @@ var require_gifutil = /* @__PURE__ */ __commonJSMin(((exports) => {
58888
58888
  }
58889
58889
  function _writeBinary(path, buffer) {
58890
58890
  return new Promise((resolve, reject) => {
58891
- fs$14.writeFile(path, buffer, (err) => {
58891
+ fs$13.writeFile(path, buffer, (err) => {
58892
58892
  if (err) return reject(err);
58893
58893
  return resolve();
58894
58894
  });
@@ -84706,7 +84706,7 @@ var init_file_type = __esmMin((() => {
84706
84706
  }
84707
84707
  async fromFile(path) {
84708
84708
  this.options.signal?.throwIfAborted();
84709
- const fileHandle = await fs.open(path, constants.O_RDONLY | constants.O_NONBLOCK);
84709
+ const fileHandle = await jn.open(path, constants.O_RDONLY | constants.O_NONBLOCK);
84710
84710
  const fileStat = await fileHandle.stat();
84711
84711
  if (!fileStat.isFile()) {
84712
84712
  await fileHandle.close();
@@ -98898,7 +98898,7 @@ function Pn(s, t) {
98898
98898
  function zn(s, t) {
98899
98899
  s.head = new ue$1(t, void 0, s.head, s), s.tail || (s.tail = s.head), s.length++;
98900
98900
  }
98901
- var kr, vr, Os, Br, Pr, zr, q$1, j$1, rt$1, Le$1, jt, Ne$1, Ts, Ae$1, xs, z$1, Mt, b$1, Qt, Bt, _$1, A$1, g$1, yi, De$1, L$1, w$1, Ri, bi, Ls, _i, Z$1, gi, Ie$1, Jt$1, yt, C, te, Ur, Hr, Wr, Gr, Ce$1, Oi, Zr, Yr, D$1, Vr, ot, H$1, ee$1, m$1, xi, J$1, Li, Ii, Ci, se$1, Fe$1, Ut$1, Ht, Ni, Pt, ht, U$1, nt$1, Y$1, zt, Ai, Q$1, ie$1, Di, ke$1, Rt, ve$1, bt, _t, Me, tt$1, Wt$1, $r, As, Ds, Is, Cs, Fs, Xr, re, K$1, jr, M$1, Qr, vs, Jr, ki, Ot, Gt, vi, ne, Be$1, Pe$1, ze$1, Ue, He$1, We$1, Ge$1, Ze$1, Ye$1, Ms, en, sn, Bs, rn, nn, Ps, zs, Bi, oe$1, hn, he$1, Ke$1, F$1, an, Tt, Pi, ln, at, cn, fn, dn, lt, un, mn, pn, zi, En, xt, ct, Sn, yn, Rn, f, Yt$1, Lt, gn, Zi, Yi, On, B$1, Nt, et$1, Ui, Us, V$1, ae$1, ft, Hs, p, it, dt, Hi, At, y$1, Ve$1, $e$1, Wi, Ws, Gs, le$1, Gi, Xe$1, Kt$1, ut, qe$1, Dt, je$1, Qe$1, Zs, Tn, st$1, mt, Nn, Ki, An, Dn, It, Vi, Cn, Ys, ce$1, Je$1, $i, Fn, kn, Xi, Ks, Js, vn, Xs, qs, js, ji, Qs, fe$1, ti, Qi, ei, Ji, ts, es, is$2, pt, ii, ss, qi, X$1, de$1, si, ri, Mn, ni, ue$1, di, tr, oi, me$1, W$1, Ct, Ft$1, pe$2, rs, G, ns, hi, er, as, ls, ai, li, ir, os$6, ci, rr, hs, Et, kt, Un, Hn, or, hr, Wn, Gn, fr, dr, ar, ur, mr, pr, Kn, Vn, $n, lr, cs, fs$13, ui, Xn, ds, qn, us, we$1, wt, Qn, Er, ms, wr, Jn, Sr, ps, yr, $t, Rr, eo, io, Ei, _r, gr, ys, Or, Rs, P$1, bs, _s, Si, Tr, xr, ye$1, Lr, Nr, Es, St, O$1, wi, Ar, Xt$1, ws, Ss, gs, Re, be, _e$1, ge$1, Oe$1, no, oo, ho, Dr, qt, Se$1, Te$1, ao, lo, co, fo, uo, mo, po, Eo, vt, So;
98901
+ var kr, vr, Os, Br, Pr, zr, q$1, j$1, rt$1, Le$1, jt, Ne$1, Ts, Ae$1, xs, z$1, Mt, b$1, Qt, Bt, _$1, A$1, g$1, yi, De$1, L$1, w$1, Ri, bi, Ls, _i, Z$1, gi, Ie$1, Jt$1, yt, C, te, Ur, Hr, Wr, Gr, Ce$1, Oi, Zr, Yr, D$1, Vr, ot, H$1, ee$1, m$1, xi, J$1, Li, Ii, Ci, se$1, Fe$1, Ut$1, Ht, Ni, Pt, ht, U$1, nt$1, Y$1, zt, Ai, Q$1, ie$1, Di, ke$1, Rt, ve$1, bt, _t, Me, tt$1, Wt$1, $r, As, Ds, Is, Cs, Fs, Xr, re, K$1, jr, M$1, Qr, vs, Jr, ki, Ot, Gt, vi, ne, Be$1, Pe$1, ze$1, Ue, He$1, We$1, Ge$1, Ze$1, Ye$1, Ms, en, sn, Bs, rn, nn, Ps, zs, Bi, oe$1, hn, he$1, Ke$1, F$1, an, Tt, Pi, ln, at, cn, fn, dn, lt, un, mn, pn, zi, En, xt, ct, Sn, yn, Rn, f, Yt$1, Lt, gn, Zi, Yi, On, B$1, Nt, et$1, Ui, Us, V$1, ae$1, ft, Hs, p, it, dt, Hi, At, y$1, Ve$1, $e$1, Wi, Ws, Gs, le$1, Gi, Xe$1, Kt$1, ut, qe$1, Dt, je$1, Qe$1, Zs, Tn, st$1, mt, Nn, Ki, An, Dn, It, Vi, Cn, Ys, ce$1, Je$1, $i, Fn, kn, Xi, Ks, Js, vn, Xs, qs, js, ji, Qs, fe$1, ti, Qi, ei, Ji, ts, es, is$2, pt, ii, ss, qi, X$1, de$1, si, ri, Mn, ni, ue$1, di, tr, oi, me$1, W$1, Ct, Ft$1, pe$2, rs, G, ns, hi, er, as, ls, ai, li, ir, os$6, ci, rr, hs, Et, kt, Un, Hn, or, hr, Wn, Gn, fr, dr, ar, ur, mr, pr, Kn, Vn, $n, lr, cs, fs$12, ui, Xn, ds, qn, us, we$1, wt, Qn, Er, ms, wr, Jn, Sr, ps, yr, $t, Rr, eo, io, Ei, _r, gr, ys, Or, Rs, P$1, bs, _s, Si, Tr, xr, ye$1, Lr, Nr, Es, St, O$1, wi, Ar, Xt$1, ws, Ss, gs, Re, be, _e$1, ge$1, Oe$1, no, oo, ho, Dr, qt, Se$1, Te$1, ao, lo, co, fo, uo, mo, po, Eo, vt, So;
98902
98902
  var init_index_min = __esmMin((() => {
98903
98903
  kr = Object.defineProperty;
98904
98904
  vr = (s, t) => {
@@ -101041,7 +101041,7 @@ while (this[Us](this[it].shift()));
101041
101041
  if (!t?.length) throw new TypeError("no paths specified to add to archive");
101042
101042
  });
101043
101043
  fr = (process.env.__FAKE_PLATFORM__ || process.platform) === "win32", {O_CREAT: dr, O_NOFOLLOW: ar, O_TRUNC: ur, O_WRONLY: mr} = I.constants, pr = Number(process.env.__FAKE_FS_O_FILENAME__) || I.constants.UV_FS_O_FILEMAP || 0, Kn = fr && !!pr, Vn = 512 * 1024, $n = pr | ur | dr | mr, lr = !fr && typeof ar == "number" ? ar | ur | dr | mr : null, cs = lr !== null ? () => lr : Kn ? (s) => s < Vn ? $n : "w" : () => "w";
101044
- fs$13 = (s, t, e) => {
101044
+ fs$12 = (s, t, e) => {
101045
101045
  try {
101046
101046
  return Vt.lchownSync(s, t, e);
101047
101047
  } catch (i) {
@@ -101073,7 +101073,7 @@ while (this[Us](this[it].shift()));
101073
101073
  for (let l of n) Xn(s, l, t, e, a);
101074
101074
  });
101075
101075
  }, qn = (s, t, e, i) => {
101076
- t.isDirectory() && us(path.resolve(s, t.name), e, i), fs$13(path.resolve(s, t.name), e, i);
101076
+ t.isDirectory() && us(path.resolve(s, t.name), e, i), fs$12(path.resolve(s, t.name), e, i);
101077
101077
  }, us = (s, t, e) => {
101078
101078
  let i;
101079
101079
  try {
@@ -101081,11 +101081,11 @@ while (this[Us](this[it].shift()));
101081
101081
  } catch (r) {
101082
101082
  let n = r;
101083
101083
  if (n?.code === "ENOENT") return;
101084
- if (n?.code === "ENOTDIR" || n?.code === "ENOTSUP") return fs$13(s, t, e);
101084
+ if (n?.code === "ENOTDIR" || n?.code === "ENOTSUP") return fs$12(s, t, e);
101085
101085
  throw n;
101086
101086
  }
101087
101087
  for (let r of i) qn(s, r, t, e);
101088
- return fs$13(s, t, e);
101088
+ return fs$12(s, t, e);
101089
101089
  };
101090
101090
  we$1 = class extends Error {
101091
101091
  path;
@@ -101120,7 +101120,7 @@ while (this[Us](this[it].shift()));
101120
101120
  E ? e(E) : x && a ? ds(x, o, h, (xe) => S(xe)) : n ? Vt.chmod(s, r, e) : e();
101121
101121
  };
101122
101122
  if (s === d) return Qn(s, S);
101123
- if (l) return fs.mkdir(s, {
101123
+ if (l) return jn.mkdir(s, {
101124
101124
  mode: r,
101125
101125
  recursive: !0
101126
101126
  }).then((E) => S(null, E ?? void 0), S);
@@ -101879,7 +101879,7 @@ var require_pend = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101879
101879
  //#endregion
101880
101880
  //#region ../../node_modules/.pnpm/yauzl@3.3.0/node_modules/yauzl/fd-slicer.js
101881
101881
  var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
101882
- var fs$12 = __require("fs");
101882
+ var fs$11 = __require("fs");
101883
101883
  var util$5 = __require("util");
101884
101884
  var stream$1 = __require("stream");
101885
101885
  var Readable = stream$1.Readable;
@@ -101904,7 +101904,7 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
101904
101904
  FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
101905
101905
  var self = this;
101906
101906
  self.pend.go(function(cb) {
101907
- fs$12.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer) {
101907
+ fs$11.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer) {
101908
101908
  cb();
101909
101909
  callback(err, bytesRead, buffer);
101910
101910
  });
@@ -101913,7 +101913,7 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
101913
101913
  FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
101914
101914
  var self = this;
101915
101915
  self.pend.go(function(cb) {
101916
- fs$12.write(self.fd, buffer, offset, length, position, function(err, written, buffer) {
101916
+ fs$11.write(self.fd, buffer, offset, length, position, function(err, written, buffer) {
101917
101917
  cb();
101918
101918
  callback(err, written, buffer);
101919
101919
  });
@@ -101933,7 +101933,7 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
101933
101933
  self.refCount -= 1;
101934
101934
  if (self.refCount > 0) return;
101935
101935
  if (self.refCount < 0) throw new Error("invalid unref");
101936
- if (self.autoClose) fs$12.close(self.fd, onCloseDone);
101936
+ if (self.autoClose) fs$11.close(self.fd, onCloseDone);
101937
101937
  function onCloseDone(err) {
101938
101938
  if (err) self.emit("error", err);
101939
101939
  else self.emit("close");
@@ -101964,7 +101964,7 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
101964
101964
  self.context.pend.go(function(cb) {
101965
101965
  if (self.destroyed) return cb();
101966
101966
  var buffer = Buffer.allocUnsafe(toRead);
101967
- fs$12.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
101967
+ fs$11.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
101968
101968
  if (err) self.destroy(err);
101969
101969
  else if (bytesRead === 0) {
101970
101970
  self.destroyed = true;
@@ -102010,7 +102010,7 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
102010
102010
  }
102011
102011
  self.context.pend.go(function(cb) {
102012
102012
  if (self.destroyed) return cb();
102013
- fs$12.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err, bytes) {
102013
+ fs$11.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err, bytes) {
102014
102014
  if (err) {
102015
102015
  self.destroy();
102016
102016
  cb();
@@ -137140,7 +137140,7 @@ var init_proxy = __esmMin((() => {
137140
137140
  var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
137141
137141
  module.exports = isexe;
137142
137142
  isexe.sync = sync;
137143
- var fs$10 = __require("fs");
137143
+ var fs$9 = __require("fs");
137144
137144
  function checkPathExt(path, options) {
137145
137145
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
137146
137146
  if (!pathext) return true;
@@ -137157,12 +137157,12 @@ var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
137157
137157
  return checkPathExt(path, options);
137158
137158
  }
137159
137159
  function isexe(path, options, cb) {
137160
- fs$10.stat(path, function(er, stat) {
137160
+ fs$9.stat(path, function(er, stat) {
137161
137161
  cb(er, er ? false : checkStat(stat, path, options));
137162
137162
  });
137163
137163
  }
137164
137164
  function sync(path, options) {
137165
- return checkStat(fs$10.statSync(path), path, options);
137165
+ return checkStat(fs$9.statSync(path), path, options);
137166
137166
  }
137167
137167
  }));
137168
137168
  //#endregion
@@ -137170,14 +137170,14 @@ var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
137170
137170
  var require_mode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
137171
137171
  module.exports = isexe;
137172
137172
  isexe.sync = sync;
137173
- var fs$9 = __require("fs");
137173
+ var fs$8 = __require("fs");
137174
137174
  function isexe(path, options, cb) {
137175
- fs$9.stat(path, function(er, stat) {
137175
+ fs$8.stat(path, function(er, stat) {
137176
137176
  cb(er, er ? false : checkStat(stat, options));
137177
137177
  });
137178
137178
  }
137179
137179
  function sync(path, options) {
137180
- return checkStat(fs$9.statSync(path), options);
137180
+ return checkStat(fs$8.statSync(path), options);
137181
137181
  }
137182
137182
  function checkStat(stat, options) {
137183
137183
  return stat.isFile() && checkMode(stat, options);
@@ -137392,16 +137392,16 @@ var require_shebang_command = /* @__PURE__ */ __commonJSMin(((exports, module) =
137392
137392
  //#endregion
137393
137393
  //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
137394
137394
  var require_readShebang = /* @__PURE__ */ __commonJSMin(((exports, module) => {
137395
- const fs$8 = __require("fs");
137395
+ const fs$7 = __require("fs");
137396
137396
  const shebangCommand = require_shebang_command();
137397
137397
  function readShebang(command) {
137398
137398
  const size = 150;
137399
137399
  const buffer = Buffer.alloc(size);
137400
137400
  let fd;
137401
137401
  try {
137402
- fd = fs$8.openSync(command, "r");
137403
- fs$8.readSync(fd, buffer, 0, size, 0);
137404
- fs$8.closeSync(fd);
137402
+ fd = fs$7.openSync(command, "r");
137403
+ fs$7.readSync(fd, buffer, 0, size, 0);
137404
+ fs$7.closeSync(fd);
137405
137405
  } catch (e) {}
137406
137406
  return shebangCommand(buffer.toString());
137407
137407
  }
@@ -155907,7 +155907,7 @@ var require_dist$5 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
155907
155907
  //#endregion
155908
155908
  //#region ../../node_modules/.pnpm/yazl@3.3.1/node_modules/yazl/index.js
155909
155909
  var require_yazl = /* @__PURE__ */ __commonJSMin(((exports) => {
155910
- var fs$7 = __require("fs");
155910
+ var fs$6 = __require("fs");
155911
155911
  var Transform$2 = __require("stream").Transform;
155912
155912
  var PassThrough$2 = __require("stream").PassThrough;
155913
155913
  var zlib$1 = __require("zlib");
@@ -155936,14 +155936,14 @@ var require_yazl = /* @__PURE__ */ __commonJSMin(((exports) => {
155936
155936
  if (shouldIgnoreAdding(self)) return;
155937
155937
  var entry = new Entry(metadataPath, false, options);
155938
155938
  self.entries.push(entry);
155939
- fs$7.stat(realPath, function(err, stats) {
155939
+ fs$6.stat(realPath, function(err, stats) {
155940
155940
  if (err) return self.emit("error", err);
155941
155941
  if (!stats.isFile()) return self.emit("error", /* @__PURE__ */ new Error("not a file: " + realPath));
155942
155942
  entry.uncompressedSize = stats.size;
155943
155943
  if (options.mtime == null) entry.setLastModDate(stats.mtime);
155944
155944
  if (options.mode == null) entry.setFileAttributesMode(stats.mode);
155945
155945
  entry.setFileDataPumpFunction(function() {
155946
- var readStream = fs$7.createReadStream(realPath);
155946
+ var readStream = fs$6.createReadStream(realPath);
155947
155947
  entry.state = Entry.FILE_DATA_IN_PROGRESS;
155948
155948
  readStream.on("error", function(err) {
155949
155949
  self.emit("error", err);
@@ -156769,7 +156769,7 @@ function extractApiErrorMessage(value) {
156769
156769
  if (message !== void 0) return message;
156770
156770
  }
156771
156771
  const error = value["error"];
156772
- const errorString = nonEmptyString$3(error);
156772
+ const errorString = nonEmptyString$4(error);
156773
156773
  if (errorString !== void 0) return errorString;
156774
156774
  if (isRecord$9(error)) for (const key of NESTED_ERROR_KEYS) {
156775
156775
  const message = stringField$3(error, key);
@@ -156791,9 +156791,9 @@ async function readApiErrorMessage(response, fallback) {
156791
156791
  return extractApiErrorMessage(parsed) ?? fallback;
156792
156792
  }
156793
156793
  function stringField$3(record, key) {
156794
- return nonEmptyString$3(record[key]);
156794
+ return nonEmptyString$4(record[key]);
156795
156795
  }
156796
- function nonEmptyString$3(value) {
156796
+ function nonEmptyString$4(value) {
156797
156797
  if (typeof value !== "string") return void 0;
156798
156798
  const trimmed = value.trim();
156799
156799
  return trimmed.length > 0 ? trimmed : void 0;
@@ -157330,7 +157330,7 @@ var require_clone = /* @__PURE__ */ __commonJSMin(((exports, module) => {
157330
157330
  //#endregion
157331
157331
  //#region ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js
157332
157332
  var require_graceful_fs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
157333
- var fs$6 = __require("fs");
157333
+ var fs$5 = __require("fs");
157334
157334
  var polyfills = require_polyfills();
157335
157335
  var legacy = require_legacy_streams();
157336
157336
  var clone = require_clone();
@@ -157359,36 +157359,36 @@ var require_graceful_fs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
157359
157359
  m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
157360
157360
  console.error(m);
157361
157361
  };
157362
- if (!fs$6[gracefulQueue]) {
157363
- publishQueue(fs$6, global[gracefulQueue] || []);
157364
- fs$6.close = (function(fs$close) {
157362
+ if (!fs$5[gracefulQueue]) {
157363
+ publishQueue(fs$5, global[gracefulQueue] || []);
157364
+ fs$5.close = (function(fs$close) {
157365
157365
  function close(fd, cb) {
157366
- return fs$close.call(fs$6, fd, function(err) {
157366
+ return fs$close.call(fs$5, fd, function(err) {
157367
157367
  if (!err) resetQueue();
157368
157368
  if (typeof cb === "function") cb.apply(this, arguments);
157369
157369
  });
157370
157370
  }
157371
157371
  Object.defineProperty(close, previousSymbol, { value: fs$close });
157372
157372
  return close;
157373
- })(fs$6.close);
157374
- fs$6.closeSync = (function(fs$closeSync) {
157373
+ })(fs$5.close);
157374
+ fs$5.closeSync = (function(fs$closeSync) {
157375
157375
  function closeSync(fd) {
157376
- fs$closeSync.apply(fs$6, arguments);
157376
+ fs$closeSync.apply(fs$5, arguments);
157377
157377
  resetQueue();
157378
157378
  }
157379
157379
  Object.defineProperty(closeSync, previousSymbol, { value: fs$closeSync });
157380
157380
  return closeSync;
157381
- })(fs$6.closeSync);
157381
+ })(fs$5.closeSync);
157382
157382
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) process.on("exit", function() {
157383
- debug(fs$6[gracefulQueue]);
157384
- __require("assert").equal(fs$6[gracefulQueue].length, 0);
157383
+ debug(fs$5[gracefulQueue]);
157384
+ __require("assert").equal(fs$5[gracefulQueue].length, 0);
157385
157385
  });
157386
157386
  }
157387
- if (!global[gracefulQueue]) publishQueue(global, fs$6[gracefulQueue]);
157388
- module.exports = patch(clone(fs$6));
157389
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs$6.__patched) {
157390
- module.exports = patch(fs$6);
157391
- fs$6.__patched = true;
157387
+ if (!global[gracefulQueue]) publishQueue(global, fs$5[gracefulQueue]);
157388
+ module.exports = patch(clone(fs$5));
157389
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs$5.__patched) {
157390
+ module.exports = patch(fs$5);
157391
+ fs$5.__patched = true;
157392
157392
  }
157393
157393
  function patch(fs) {
157394
157394
  polyfills(fs);
@@ -157643,23 +157643,23 @@ var require_graceful_fs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
157643
157643
  }
157644
157644
  function enqueue(elem) {
157645
157645
  debug("ENQUEUE", elem[0].name, elem[1]);
157646
- fs$6[gracefulQueue].push(elem);
157646
+ fs$5[gracefulQueue].push(elem);
157647
157647
  retry();
157648
157648
  }
157649
157649
  var retryTimer;
157650
157650
  function resetQueue() {
157651
157651
  var now = Date.now();
157652
- for (var i = 0; i < fs$6[gracefulQueue].length; ++i) if (fs$6[gracefulQueue][i].length > 2) {
157653
- fs$6[gracefulQueue][i][3] = now;
157654
- fs$6[gracefulQueue][i][4] = now;
157652
+ for (var i = 0; i < fs$5[gracefulQueue].length; ++i) if (fs$5[gracefulQueue][i].length > 2) {
157653
+ fs$5[gracefulQueue][i][3] = now;
157654
+ fs$5[gracefulQueue][i][4] = now;
157655
157655
  }
157656
157656
  retry();
157657
157657
  }
157658
157658
  function retry() {
157659
157659
  clearTimeout(retryTimer);
157660
157660
  retryTimer = void 0;
157661
- if (fs$6[gracefulQueue].length === 0) return;
157662
- var elem = fs$6[gracefulQueue].shift();
157661
+ if (fs$5[gracefulQueue].length === 0) return;
157662
+ var elem = fs$5[gracefulQueue].shift();
157663
157663
  var fn = elem[0];
157664
157664
  var args = elem[1];
157665
157665
  var err = elem[2];
@@ -157678,7 +157678,7 @@ var require_graceful_fs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
157678
157678
  if (sinceAttempt >= Math.min(sinceStart * 1.2, 100)) {
157679
157679
  debug("RETRY", fn.name, args);
157680
157680
  fn.apply(null, args.concat([startTime]));
157681
- } else fs$6[gracefulQueue].push(elem);
157681
+ } else fs$5[gracefulQueue].push(elem);
157682
157682
  }
157683
157683
  if (retryTimer === void 0) retryTimer = setTimeout(retry, 0);
157684
157684
  }
@@ -158705,12 +158705,16 @@ var BLUN_PLATFORM, BLUN_CUSTOM_HEADERS_ENV;
158705
158705
  var init_identity = __esmMin((() => {
158706
158706
  BLUN_PLATFORM = "blun_code_cli";
158707
158707
  BLUN_CUSTOM_HEADERS_ENV = "BLUN_CUSTOM_HEADERS";
158708
- })), BLUN_FLOW_CONFIG;
158708
+ }));
158709
+ //#endregion
158710
+ //#region ../../packages/oauth/src/constants.ts
158711
+ var DEFAULT_BLUN_OAUTH_HOST, BLUN_FLOW_CONFIG;
158709
158712
  var init_constants$2 = __esmMin((() => {
158713
+ DEFAULT_BLUN_OAUTH_HOST = "https://account.blun.ai";
158710
158714
  BLUN_FLOW_CONFIG = {
158711
158715
  name: "blun",
158712
- oauthHost: process.env["BLUN_OAUTH_HOST"] ?? "https://auth.blun.ai",
158713
- clientId: "17e5f671-d194-4dfb-9706-5516cb48c098"
158716
+ oauthHost: process.env["BLUN_OAUTH_HOST"] ?? "https://account.blun.ai",
158717
+ clientId: "blun-code"
158714
158718
  };
158715
158719
  }));
158716
158720
  //#endregion
@@ -158719,10 +158723,41 @@ var init_provider_refresh_wrapper = __esmMin((() => {}));
158719
158723
  //#endregion
158720
158724
  //#region ../../packages/oauth/src/managed-usage.ts
158721
158725
  function blunCodeBaseUrl() {
158722
- return process.env["BLUN_BASE_URL"] ?? "https://api.blun.ai/coding/v1";
158726
+ return process.env["BLUN_BASE_URL"] ?? "https://api.blun.ai/v1";
158723
158727
  }
158724
- function blunCodeUsageUrl() {
158725
- return `${blunCodeBaseUrl().replace(/\/+$/, "")}/usages`;
158728
+ function blunCodeAuxiliaryBaseUrl(baseUrl) {
158729
+ const normalized = (baseUrl ?? blunCodeBaseUrl()).replace(/\/+$/, "");
158730
+ return normalized === "https://api.blun.ai/v1" ? DEFAULT_BLUN_AUXILIARY_BASE_URL : normalized;
158731
+ }
158732
+ function blunContextWindowsUrl(oauthHost) {
158733
+ return `${(oauthHost ?? process.env["BLUN_OAUTH_HOST"] ?? "https://account.blun.ai").replace(/\/+$/, "")}/api/verbrauch/tarife`;
158734
+ }
158735
+ function parseManagedContextWindow(payload, plan) {
158736
+ if (!isRecord$9(payload)) return void 0;
158737
+ const contextWindows = payload["kontext"];
158738
+ if (!isRecord$9(contextWindows)) return void 0;
158739
+ const value = contextWindows[plan];
158740
+ return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : void 0;
158741
+ }
158742
+ async function fetchManagedContextWindow(url, plan, opts = {}) {
158743
+ const controller = new AbortController();
158744
+ const timer = setTimeout(() => {
158745
+ controller.abort();
158746
+ }, opts.timeoutMs ?? 8e3);
158747
+ timer.unref?.();
158748
+ try {
158749
+ const response = await fetch(url, {
158750
+ headers: { Accept: "application/json" },
158751
+ signal: controller.signal,
158752
+ redirect: "error"
158753
+ });
158754
+ if (!response.ok) return void 0;
158755
+ return parseManagedContextWindow(await response.json(), plan);
158756
+ } catch {
158757
+ return;
158758
+ } finally {
158759
+ clearTimeout(timer);
158760
+ }
158726
158761
  }
158727
158762
  function parseManagedUsagePayload(payload) {
158728
158763
  if (typeof payload !== "object" || payload === null) return {
@@ -158732,8 +158767,17 @@ function parseManagedUsagePayload(payload) {
158732
158767
  const rec = payload;
158733
158768
  const summary = toUsageRow(rec["usage"], "Weekly limit");
158734
158769
  const limits = [];
158770
+ const accountId = managedAccountIdFrom(rec["account_id"]);
158771
+ const plan = typeof rec["plan"] === "string" && rec["plan"].trim().length > 0 ? rec["plan"].trim() : void 0;
158772
+ const contextWindowTokens = managedContextWindowFrom(rec);
158773
+ const unlimited = rec["unlimited"] === true;
158774
+ const stand = isRecord$9(rec["stand"]) ? rec["stand"] : void 0;
158775
+ if (stand !== void 0) for (const [sourceKey, id, label] of ACCOUNT_USAGE_WINDOWS) {
158776
+ const row = toAccountUsageRow(stand[sourceKey], id, label, unlimited);
158777
+ if (row !== null) limits.push(row);
158778
+ }
158735
158779
  const rawLimits = rec["limits"];
158736
- if (Array.isArray(rawLimits)) for (let idx = 0; idx < rawLimits.length; idx++) {
158780
+ if (stand === void 0 && Array.isArray(rawLimits)) for (let idx = 0; idx < rawLimits.length; idx++) {
158737
158781
  const item = rawLimits[idx];
158738
158782
  if (!item || typeof item !== "object") continue;
158739
158783
  const detailRaw = item["detail"];
@@ -158743,26 +158787,88 @@ function parseManagedUsagePayload(payload) {
158743
158787
  if (row !== null) limits.push(row);
158744
158788
  }
158745
158789
  return {
158790
+ ...accountId === void 0 ? {} : { accountId },
158791
+ ...plan === void 0 ? {} : { plan },
158792
+ ...contextWindowTokens === void 0 ? {} : { contextWindowTokens },
158746
158793
  summary,
158747
158794
  limits
158748
158795
  };
158749
158796
  }
158797
+ function managedAccountIdFrom(value) {
158798
+ if (typeof value !== "string") return void 0;
158799
+ const normalized = value.trim();
158800
+ return normalized.length > 0 && normalized.length <= 512 ? normalized : void 0;
158801
+ }
158802
+ function managedContextWindowFrom(payload) {
158803
+ const values = [payload["context_window_tokens"], payload["contextWindowTokens"]].filter((value) => value !== void 0);
158804
+ if (values.length === 0) return void 0;
158805
+ if (values.some((value) => !Number.isSafeInteger(value) || value <= 0)) return;
158806
+ const [first] = values;
158807
+ return values.every((value) => value === first) ? first : void 0;
158808
+ }
158809
+ function toAccountUsageRow(raw, id, label, accountUnlimited) {
158810
+ if (!isRecord$9(raw)) return null;
158811
+ const used = toInt(raw["verbraucht"]);
158812
+ const unlimited = accountUnlimited || raw["unlimited"] === true;
158813
+ const fraction = raw["anteil"];
158814
+ const resetAt = typeof raw["zuruecksetzung"] === "string" && raw["zuruecksetzung"].length > 0 ? raw["zuruecksetzung"] : void 0;
158815
+ if (unlimited) {
158816
+ if (used === null || used < 0) return null;
158817
+ return {
158818
+ id,
158819
+ label,
158820
+ used,
158821
+ limit: 0,
158822
+ unlimited: true,
158823
+ resetAt,
158824
+ resetHint: resetAt === void 0 ? void 0 : formatResetTime(resetAt)
158825
+ };
158826
+ }
158827
+ if (typeof fraction !== "number" || !Number.isFinite(fraction) || fraction < 0) return null;
158828
+ const limit = toInt(raw["grenze"]);
158829
+ const remaining = toInt(raw["uebrig"]);
158830
+ if (used === null || limit === null || remaining === null || used < 0 || limit < 0 || remaining < 0 || remaining !== Math.max(limit - used, 0)) return null;
158831
+ return {
158832
+ id,
158833
+ label,
158834
+ used,
158835
+ limit,
158836
+ fraction,
158837
+ remaining,
158838
+ resetAt,
158839
+ resetHint: resetAt === void 0 ? void 0 : formatResetTime(resetAt)
158840
+ };
158841
+ }
158750
158842
  function toUsageRow(raw, defaultLabel) {
158751
158843
  if (!isRecord$9(raw)) return null;
158844
+ const unlimited = raw["unlimited"] === true;
158752
158845
  const limit = toInt(raw["limit"]);
158753
158846
  let used = toInt(raw["used"]);
158847
+ const remaining = toInt(raw["remaining"]);
158848
+ if (unlimited) {
158849
+ if (used === null || used < 0) return null;
158850
+ const name = typeof raw["name"] === "string" ? raw["name"] : typeof raw["label"] === "string" ? raw["label"] : defaultLabel;
158851
+ const resetHint = resetHintFrom(raw);
158852
+ return {
158853
+ label: name,
158854
+ used,
158855
+ limit: 0,
158856
+ unlimited: true,
158857
+ ...resetHint === void 0 ? {} : { resetHint }
158858
+ };
158859
+ }
158754
158860
  if (used === null) {
158755
- const remaining = toInt(raw["remaining"]);
158756
158861
  if (remaining !== null && limit !== null) used = limit - remaining;
158757
158862
  }
158758
- if (used === null && limit === null) return null;
158863
+ if (used === null || limit === null || used < 0 || limit < 0 || remaining !== null && (remaining < 0 || remaining !== Math.max(limit - used, 0))) return null;
158759
158864
  const name = typeof raw["name"] === "string" ? raw["name"] : typeof raw["title"] === "string" ? raw["title"] : defaultLabel;
158760
158865
  const resetHint = resetHintFrom(raw);
158761
158866
  return {
158762
158867
  label: name,
158763
- used: used ?? 0,
158764
- limit: limit ?? 0,
158765
- resetHint
158868
+ used,
158869
+ limit,
158870
+ ...remaining === null ? {} : { remaining },
158871
+ ...resetHint === void 0 ? {} : { resetHint }
158766
158872
  };
158767
158873
  }
158768
158874
  function limitLabel(item, detail, window, idx) {
@@ -158842,49 +158948,124 @@ function toInt(value) {
158842
158948
  }
158843
158949
  return null;
158844
158950
  }
158951
+ async function managedUsageErrorCode(response) {
158952
+ if (response.status === 401) return "unauthenticated";
158953
+ if (response.status !== 403) return "unavailable";
158954
+ return isManagedQuotaErrorMessage(await readApiErrorMessage(response, "")) ? "unavailable" : "unauthenticated";
158955
+ }
158956
+ function isManagedQuotaErrorMessage(message) {
158957
+ if (message === void 0) return false;
158958
+ const normalized = message.toLowerCase();
158959
+ if (/\bquota\b.*\b(?:exceeded|exhausted|limit(?:ed)?)\b/.test(normalized)) return true;
158960
+ if (/\b(?:insufficient|no) credits?\b|\bpayment required\b/.test(normalized)) return true;
158961
+ return /you(?:'|’)?ve reached your usage limit/.test(normalized) && /billing cycle|quota will be (?:refreshed|reset)|purchase extra usage/.test(normalized);
158962
+ }
158963
+ function hasManagedUsageShape(payload) {
158964
+ if (!isRecord$9(payload)) return false;
158965
+ let recognized = false;
158966
+ if ("context_window_tokens" in payload || "contextWindowTokens" in payload) {
158967
+ recognized = true;
158968
+ if (managedContextWindowFrom(payload) === void 0) return false;
158969
+ }
158970
+ if ("usage" in payload) {
158971
+ recognized = true;
158972
+ if (payload["usage"] !== null && toUsageRow(payload["usage"], "Weekly limit") === null) return false;
158973
+ }
158974
+ if ("limits" in payload) {
158975
+ recognized = true;
158976
+ const limits = payload["limits"];
158977
+ if (!Array.isArray(limits)) return false;
158978
+ for (let index = 0; index < limits.length; index++) {
158979
+ const item = limits[index];
158980
+ if (!isRecord$9(item)) return false;
158981
+ const detail = isRecord$9(item["detail"]) ? item["detail"] : item;
158982
+ if (toUsageRow(detail, limitLabel(item, detail, isRecord$9(item["window"]) ? item["window"] : {}, index)) === null) return false;
158983
+ }
158984
+ }
158985
+ if ("stand" in payload) {
158986
+ recognized = true;
158987
+ const stand = payload["stand"];
158988
+ if (!isRecord$9(stand)) return false;
158989
+ const windows = ACCOUNT_USAGE_WINDOWS.filter(([sourceKey]) => sourceKey in stand);
158990
+ if (windows.length === 0) return false;
158991
+ const unlimited = payload["unlimited"] === true;
158992
+ for (const [sourceKey, id, label] of windows) if (toAccountUsageRow(stand[sourceKey], id, label, unlimited) === null) return false;
158993
+ }
158994
+ return recognized;
158995
+ }
158845
158996
  async function fetchManagedUsage(url, accessToken, opts = {}) {
158846
158997
  const controller = new AbortController();
158847
158998
  const timer = setTimeout(() => {
158848
158999
  controller.abort();
158849
159000
  }, opts.timeoutMs ?? 8e3);
159001
+ timer.unref?.();
158850
159002
  try {
158851
159003
  const res = await fetch(url, {
158852
159004
  headers: {
158853
159005
  Authorization: `Bearer ${accessToken}`,
158854
159006
  Accept: "application/json"
158855
159007
  },
158856
- signal: controller.signal
159008
+ signal: controller.signal,
159009
+ redirect: "error"
158857
159010
  });
158858
159011
  if (!res.ok) {
158859
159012
  const status = res.status;
158860
159013
  return {
158861
159014
  kind: "error",
158862
- status,
158863
- message: await readApiErrorMessage(res, status === 401 ? "Authorization failed. Please check your API key (try /login)." : status === 404 ? "Usage endpoint not available. Try Blun For Coding." : `Failed to fetch usage: HTTP ${String(status)}`)
159015
+ code: await managedUsageErrorCode(res),
159016
+ status
158864
159017
  };
158865
159018
  }
159019
+ let json;
159020
+ try {
159021
+ json = await res.json();
159022
+ } catch {
159023
+ return {
159024
+ kind: "error",
159025
+ code: "invalid_payload"
159026
+ };
159027
+ }
159028
+ if (!hasManagedUsageShape(json)) return {
159029
+ kind: "error",
159030
+ code: "invalid_payload"
159031
+ };
158866
159032
  return {
158867
159033
  kind: "ok",
158868
- parsed: parseManagedUsagePayload(await res.json())
158869
- };
158870
- } catch (error) {
158871
- if (error instanceof Error && error.name === "AbortError") return {
158872
- kind: "error",
158873
- message: "Failed to fetch usage: request timed out."
159034
+ parsed: parseManagedUsagePayload(json)
158874
159035
  };
159036
+ } catch {
158875
159037
  return {
158876
159038
  kind: "error",
158877
- message: `Failed to fetch usage: ${error instanceof Error ? error.message : String(error)}`
159039
+ code: "unavailable"
158878
159040
  };
158879
159041
  } finally {
158880
159042
  clearTimeout(timer);
158881
159043
  }
158882
159044
  }
158883
- var DEFAULT_BLUN_BASE_URL;
159045
+ var DEFAULT_BLUN_BASE_URL, DEFAULT_BLUN_AUXILIARY_BASE_URL, ACCOUNT_USAGE_WINDOWS;
158884
159046
  var init_managed_usage = __esmMin((() => {
158885
159047
  init_api_error();
159048
+ init_constants$2();
158886
159049
  init_utils();
158887
- DEFAULT_BLUN_BASE_URL = "https://api.blun.ai/coding/v1";
159050
+ DEFAULT_BLUN_BASE_URL = "https://api.blun.ai/v1";
159051
+ DEFAULT_BLUN_AUXILIARY_BASE_URL = "https://api.blun.ai/coding/v1";
159052
+ ACCOUNT_USAGE_WINDOWS = [
159053
+ [
159054
+ "fuenf_stunden",
159055
+ "five_hours",
159056
+ "5h"
159057
+ ],
159058
+ [
159059
+ "sieben_tage",
159060
+ "seven_days",
159061
+ "7d"
159062
+ ],
159063
+ [
159064
+ "monat",
159065
+ "month",
159066
+ "month"
159067
+ ]
159068
+ ];
158888
159069
  }));
158889
159070
  //#endregion
158890
159071
  //#region ../../packages/oauth/src/model-alias-merge.ts
@@ -158969,8 +159150,8 @@ function normalizeEndpoint(value) {
158969
159150
  }
158970
159151
  function persistedOAuthHost(options) {
158971
159152
  const oauthHost = options.oauthHost;
158972
- const normalized = normalizeEndpoint(oauthHost ?? "https://auth.blun.ai");
158973
- if (options.key === "oauth/blun" && normalized === normalizeEndpoint("https://auth.blun.ai")) return;
159153
+ const normalized = normalizeEndpoint(oauthHost ?? "https://account.blun.ai");
159154
+ if (options.key === "oauth/blun" && normalized === normalizeEndpoint("https://account.blun.ai")) return;
158974
159155
  return normalized;
158975
159156
  }
158976
159157
  function managedOAuthRef(options) {
@@ -158998,9 +159179,9 @@ function blunCodeEnvOAuthHost(env = process.env) {
158998
159179
  return env.BLUN_OAUTH_HOST;
158999
159180
  }
159000
159181
  function resolveBlunCodeOAuthKey(options) {
159001
- const oauthHost = normalizeEndpoint(options.oauthHost ?? "https://auth.blun.ai");
159182
+ const oauthHost = normalizeEndpoint(options.oauthHost ?? "https://account.blun.ai");
159002
159183
  const baseUrl = defaultBaseUrl(options.baseUrl);
159003
- if (oauthHost === normalizeEndpoint("https://auth.blun.ai") && SHARED_DEFAULT_BASE_URLS.includes(baseUrl)) return BLUN_OAUTH_KEY;
159184
+ if (SHARED_DEFAULT_OAUTH_HOSTS.has(oauthHost) && SHARED_DEFAULT_BASE_URLS.has(baseUrl)) return BLUN_OAUTH_KEY;
159004
159185
  return `${BLUN_SCOPED_OAUTH_KEY_PREFIX}${createHash("sha256").update(JSON.stringify({
159005
159186
  oauthHost,
159006
159187
  baseUrl
@@ -159079,11 +159260,22 @@ function resolveBlunCodeLoginAuth(options) {
159079
159260
  oauthHost
159080
159261
  };
159081
159262
  }
159263
+ function parseModelContextLength(item, modelId) {
159264
+ let contextLength;
159265
+ for (const field of MODEL_CONTEXT_LENGTH_FIELDS) {
159266
+ if (!Object.hasOwn(item, field)) continue;
159267
+ const length = Number(item[field]);
159268
+ if (!Number.isInteger(length) || length <= 0) throw new Error(`Model "${modelId}" must include a positive context_length, max_model_len, or context_window.`);
159269
+ if (contextLength !== void 0 && contextLength !== length) throw new Error(`Model "${modelId}" reports conflicting context length values.`);
159270
+ contextLength = length;
159271
+ }
159272
+ if (contextLength === void 0) throw new Error(`Model "${modelId}" must include a positive context_length, max_model_len, or context_window.`);
159273
+ return contextLength;
159274
+ }
159082
159275
  function toModelInfo$1(item, blunOnly) {
159083
159276
  if (!isRecord$9(item) || typeof item["id"] !== "string" || item["id"].length === 0) return;
159084
159277
  if (blunOnly && !isNativeModelProtocol(item["protocol"])) return void 0;
159085
- const contextLength = Number(item["context_length"]);
159086
- if (!Number.isInteger(contextLength) || contextLength <= 0) throw new Error(`BLUN model "${item["id"]}" must include a positive context_length.`);
159278
+ const contextLength = parseModelContextLength(item, item["id"]);
159087
159279
  const displayName = item["display_name"];
159088
159280
  const normalizedDisplayName = typeof displayName === "string" && displayName.length > 0 ? displayName : void 0;
159089
159281
  const supportsToolUse = Object.hasOwn(item, "supports_tool_use") ? Boolean(item["supports_tool_use"]) : true;
@@ -159138,6 +159330,7 @@ async function fetchManagedBlunCodeModels(options) {
159138
159330
  const baseUrl = defaultBaseUrl(options.baseUrl);
159139
159331
  const response = await fetchImpl(`${baseUrl}/models`, {
159140
159332
  signal: options.signal,
159333
+ redirect: "error",
159141
159334
  headers: {
159142
159335
  ...parseBlunCodeCustomHeaders(),
159143
159336
  ...options.headers,
@@ -159208,15 +159401,16 @@ function applyManagedBlunCodeConfig(config, options) {
159208
159401
  ...config.thinking,
159209
159402
  enabled: selectedDefault.thinking
159210
159403
  };
159404
+ const auxiliaryBaseUrl = blunCodeAuxiliaryBaseUrl(baseUrl);
159211
159405
  config.services = {
159212
159406
  ...config.services,
159213
159407
  blunSearch: {
159214
- baseUrl: `${baseUrl}/search`,
159408
+ baseUrl: `${auxiliaryBaseUrl}/search`,
159215
159409
  apiKey,
159216
159410
  oauth
159217
159411
  },
159218
159412
  blunFetch: {
159219
- baseUrl: `${baseUrl}/fetch`,
159413
+ baseUrl: `${auxiliaryBaseUrl}/fetch`,
159220
159414
  apiKey,
159221
159415
  oauth
159222
159416
  }
@@ -159294,7 +159488,7 @@ async function provisionManagedBlunCodeConfig(options) {
159294
159488
  configPath: options.adapter.configPath
159295
159489
  };
159296
159490
  }
159297
- var BLUN_PLATFORM_ID, BLUN_PROVIDER_NAME$1, BLUN_OAUTH_KEY, BLUN_SCOPED_OAUTH_KEY_PREFIX, ManagedBlunCodeModelsAuthError, SHARED_DEFAULT_BASE_URLS;
159491
+ var BLUN_PLATFORM_ID, BLUN_PROVIDER_NAME$1, BLUN_OAUTH_KEY, BLUN_SCOPED_OAUTH_KEY_PREFIX, ManagedBlunCodeModelsAuthError, SHARED_DEFAULT_BASE_URLS, SHARED_DEFAULT_OAUTH_HOSTS, MODEL_CONTEXT_LENGTH_FIELDS;
159298
159492
  var init_managed_blun = __esmMin((() => {
159299
159493
  init_provider_refresh_wrapper();
159300
159494
  init_api_error();
@@ -159318,12 +159512,135 @@ var init_managed_blun = __esmMin((() => {
159318
159512
  this.baseUrl = options.baseUrl;
159319
159513
  }
159320
159514
  };
159321
- SHARED_DEFAULT_BASE_URLS = [normalizeEndpoint(DEFAULT_BLUN_BASE_URL)];
159515
+ SHARED_DEFAULT_BASE_URLS = new Set([normalizeEndpoint(DEFAULT_BLUN_BASE_URL), normalizeEndpoint(DEFAULT_BLUN_AUXILIARY_BASE_URL)]);
159516
+ SHARED_DEFAULT_OAUTH_HOSTS = new Set([normalizeEndpoint(DEFAULT_BLUN_OAUTH_HOST), normalizeEndpoint("https://auth.blun.ai")]);
159517
+ MODEL_CONTEXT_LENGTH_FIELDS = [
159518
+ "context_length",
159519
+ "max_model_len",
159520
+ "context_window"
159521
+ ];
159522
+ }));
159523
+ //#endregion
159524
+ //#region ../../packages/oauth/src/managed-quota.ts
159525
+ function blunManagedQuotaUrl(oauthHost) {
159526
+ return `${(oauthHost ?? process.env["BLUN_OAUTH_HOST"] ?? "https://account.blun.ai").replace(/\/+$/, "")}${MANAGED_QUOTA_PATH}`;
159527
+ }
159528
+ function parseManagedQuotaPayload(payload) {
159529
+ if (!isRecord$9(payload)) return void 0;
159530
+ const plan = nonEmptyString$3(payload["plan"]);
159531
+ const paid = payload["bezahlt"];
159532
+ const creditCents = payload["guthaben_cent"];
159533
+ const billingKind = nonEmptyString$3(payload["art"]);
159534
+ const globalUnlimited = payload["unlimited"];
159535
+ if (plan === void 0 || typeof paid !== "boolean" || !Number.isSafeInteger(creditCents) || creditCents < 0 || billingKind === void 0 || globalUnlimited !== void 0 && typeof globalUnlimited !== "boolean" || !isRecord$9(payload["stand"])) return;
159536
+ if (!hasStrictQuotaStand(payload["stand"], globalUnlimited === true)) return void 0;
159537
+ const limits = parseManagedUsagePayload(payload).limits;
159538
+ if (limits.length !== REQUIRED_WINDOWS.length || REQUIRED_WINDOWS.some(([, id]) => limits.filter((row) => row.id === id).length !== 1)) return;
159539
+ return {
159540
+ plan,
159541
+ paid,
159542
+ creditCents,
159543
+ billingKind,
159544
+ limits
159545
+ };
159546
+ }
159547
+ async function fetchManagedQuota(url, accessToken, opts = {}) {
159548
+ const controller = new AbortController();
159549
+ const timer = setTimeout(() => {
159550
+ controller.abort();
159551
+ }, opts.timeoutMs ?? 8e3);
159552
+ timer.unref?.();
159553
+ try {
159554
+ const response = await fetch(url, {
159555
+ headers: {
159556
+ Authorization: `Bearer ${accessToken}`,
159557
+ Accept: "application/json"
159558
+ },
159559
+ signal: controller.signal,
159560
+ redirect: "error"
159561
+ });
159562
+ if (!response.ok) return {
159563
+ kind: "error",
159564
+ code: await managedQuotaErrorCode(response),
159565
+ status: response.status
159566
+ };
159567
+ let payload;
159568
+ try {
159569
+ payload = await response.json();
159570
+ } catch {
159571
+ return {
159572
+ kind: "error",
159573
+ code: "invalid_payload"
159574
+ };
159575
+ }
159576
+ const parsed = parseManagedQuotaPayload(payload);
159577
+ return parsed === void 0 ? {
159578
+ kind: "error",
159579
+ code: "invalid_payload"
159580
+ } : {
159581
+ kind: "ok",
159582
+ parsed
159583
+ };
159584
+ } catch {
159585
+ return {
159586
+ kind: "error",
159587
+ code: "unavailable"
159588
+ };
159589
+ } finally {
159590
+ clearTimeout(timer);
159591
+ }
159592
+ }
159593
+ async function managedQuotaErrorCode(response) {
159594
+ if (response.status === 401) return "unauthenticated";
159595
+ if (response.status !== 403) return "unavailable";
159596
+ return isManagedQuotaErrorMessage(await readApiErrorMessage(response, "")) ? "unavailable" : "unauthenticated";
159597
+ }
159598
+ function nonEmptyString$3(value) {
159599
+ if (typeof value !== "string") return void 0;
159600
+ const normalized = value.trim();
159601
+ return normalized.length === 0 ? void 0 : normalized;
159602
+ }
159603
+ function hasStrictQuotaStand(stand, globalUnlimited) {
159604
+ return REQUIRED_WINDOWS.every(([sourceKey]) => {
159605
+ const row = stand[sourceKey];
159606
+ if (!isRecord$9(row)) return false;
159607
+ const used = row["verbraucht"];
159608
+ const rowUnlimited = row["unlimited"];
159609
+ if (rowUnlimited !== void 0 && typeof rowUnlimited !== "boolean") return false;
159610
+ const resetAt = row["zuruecksetzung"];
159611
+ if (!hasValidResetAt(resetAt)) return false;
159612
+ if (globalUnlimited || rowUnlimited === true) return isNonNegativeSafeInteger(used);
159613
+ const limit = row["grenze"];
159614
+ const remaining = row["uebrig"];
159615
+ const fraction = row["anteil"];
159616
+ return isNonNegativeSafeInteger(used) && isNonNegativeSafeInteger(limit) && isNonNegativeSafeInteger(remaining) && remaining === Math.max(limit - used, 0) && typeof fraction === "number" && Number.isFinite(fraction) && fraction >= 0;
159617
+ });
159618
+ }
159619
+ function isNonNegativeSafeInteger(value) {
159620
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
159621
+ }
159622
+ function hasValidResetAt(value) {
159623
+ if (value === null) return true;
159624
+ if (typeof value !== "string") return false;
159625
+ return /(?:Z|[+-]\d{2}:\d{2})$/i.test(value) && Number.isFinite(Date.parse(value));
159626
+ }
159627
+ var MANAGED_QUOTA_PATH, REQUIRED_WINDOWS;
159628
+ var init_managed_quota = __esmMin((() => {
159629
+ init_constants$2();
159630
+ init_api_error();
159631
+ init_managed_usage();
159632
+ init_utils();
159633
+ MANAGED_QUOTA_PATH = "/api/verbrauch/mein-stand";
159634
+ REQUIRED_WINDOWS = [
159635
+ ["fuenf_stunden", "five_hours"],
159636
+ ["sieben_tage", "seven_days"],
159637
+ ["monat", "month"]
159638
+ ];
159322
159639
  }));
159323
159640
  //#endregion
159324
159641
  //#region ../../packages/oauth/src/managed-feedback.ts
159325
159642
  function blunCodeFeedbackUrl(baseUrl) {
159326
- return `${(baseUrl ?? blunCodeBaseUrl()).replace(/\/+$/, "")}/feedback`;
159643
+ return `${blunCodeAuxiliaryBaseUrl(baseUrl)}/feedback`;
159327
159644
  }
159328
159645
  async function fetchSubmitFeedback(url, accessToken, body, opts = {}) {
159329
159646
  const controller = new AbortController();
@@ -159450,7 +159767,7 @@ async function postJson(url, accessToken, body, opts) {
159450
159767
  }
159451
159768
  }
159452
159769
  function feedbackBaseUrl(baseUrl) {
159453
- return (baseUrl ?? blunCodeBaseUrl()).replace(/\/+$/, "");
159770
+ return blunCodeAuxiliaryBaseUrl(baseUrl);
159454
159771
  }
159455
159772
  function readUpload(payload) {
159456
159773
  const upload = readRecord(payload, "upload");
@@ -159541,10 +159858,6 @@ function defaultBlunHome() {
159541
159858
  if (override !== void 0 && override.length > 0) return override;
159542
159859
  return join(homedir(), ".blun");
159543
159860
  }
159544
- function managedUsageUrl(baseUrl) {
159545
- if (baseUrl === void 0) return blunCodeUsageUrl();
159546
- return `${baseUrl.replace(/\/+$/, "")}/usages`;
159547
- }
159548
159861
  function managedFeedbackUrl(baseUrl) {
159549
159862
  return blunCodeFeedbackUrl(baseUrl);
159550
159863
  }
@@ -159559,6 +159872,7 @@ var init_toolkit = __esmMin((() => {
159559
159872
  init_managed_feedback();
159560
159873
  init_managed_feedback_upload();
159561
159874
  init_managed_blun();
159875
+ init_managed_quota();
159562
159876
  init_managed_usage();
159563
159877
  init_oauth_manager();
159564
159878
  init_storage();
@@ -159751,18 +160065,40 @@ var init_toolkit = __esmMin((() => {
159751
160065
  async getManagedUsage(providerName, options = {}) {
159752
160066
  const name = providerName ?? "managed:blun";
159753
160067
  try {
159754
- const accessToken = await this.ensureFresh(name, { oauthRef: options.oauthRef ?? this.defaultOAuthRef(options.baseUrl) });
159755
- const result = await fetchManagedUsage(managedUsageUrl(options.baseUrl), accessToken);
160068
+ const oauthRef = options.oauthRef ?? this.defaultOAuthRef(options.baseUrl);
160069
+ const accessToken = await this.ensureFresh(name, { oauthRef });
160070
+ const oauthHost = this.oauthHostFor(oauthRef);
160071
+ const result = await fetchManagedUsage(blunManagedQuotaUrl(oauthHost), accessToken);
159756
160072
  if (result.kind === "error") return result;
160073
+ const contextWindowTokens = result.parsed.contextWindowTokens ?? (result.parsed.plan === void 0 ? void 0 : await fetchManagedContextWindow(blunContextWindowsUrl(oauthHost), result.parsed.plan));
159757
160074
  return {
159758
160075
  kind: "ok",
159759
- summary: result.parsed.summary,
159760
- limits: result.parsed.limits
160076
+ ...result.parsed,
160077
+ ...contextWindowTokens === void 0 ? {} : { contextWindowTokens }
159761
160078
  };
159762
160079
  } catch (error) {
160080
+ if (error instanceof OAuthUnauthorizedError) return {
160081
+ kind: "error",
160082
+ code: "unauthenticated"
160083
+ };
159763
160084
  return {
159764
160085
  kind: "error",
159765
- message: error instanceof Error ? error.message : String(error)
160086
+ code: "unavailable"
160087
+ };
160088
+ }
160089
+ }
160090
+ async getManagedQuota(providerName, oauthRef = this.defaultOAuthRef()) {
160091
+ try {
160092
+ const accessToken = await this.ensureFresh(providerName ?? "managed:blun", { oauthRef });
160093
+ const result = await fetchManagedQuota(blunManagedQuotaUrl(this.oauthHostFor(oauthRef)), accessToken);
160094
+ return result.kind === "ok" ? {
160095
+ kind: "ok",
160096
+ ...result.parsed
160097
+ } : result;
160098
+ } catch (error) {
160099
+ return {
160100
+ kind: "error",
160101
+ code: error instanceof OAuthUnauthorizedError ? "unauthenticated" : "unavailable"
159766
160102
  };
159767
160103
  }
159768
160104
  }
@@ -160147,6 +160483,7 @@ var init_src$1 = __esmMin((() => {
160147
160483
  init_constants$2();
160148
160484
  init_managed_blun();
160149
160485
  init_managed_usage();
160486
+ init_managed_quota();
160150
160487
  init_managed_feedback();
160151
160488
  init_managed_feedback_upload();
160152
160489
  init_open_platform();
@@ -172569,6 +172906,22 @@ var BlunAuthFacade = class {
172569
172906
  baseUrl: auth.baseUrl
172570
172907
  });
172571
172908
  }
172909
+ async getManagedQuota(providerName) {
172910
+ const auth = this.resolveManagedAuth(providerName);
172911
+ const apiKey = auth.apiKey?.trim();
172912
+ if (apiKey) {
172913
+ if (auth.oauthRef !== void 0 || auth.baseUrl !== void 0 && auth.baseUrl.replace(/\/+$/, "") !== "https://api.blun.ai/v1") return {
172914
+ kind: "error",
172915
+ code: "unavailable"
172916
+ };
172917
+ const result = await fetchManagedQuota(blunManagedQuotaUrl(DEFAULT_BLUN_OAUTH_HOST), apiKey);
172918
+ return result.kind === "ok" ? {
172919
+ kind: "ok",
172920
+ ...result.parsed
172921
+ } : result;
172922
+ }
172923
+ return this.toolkit.getManagedQuota(providerName, this.resolveRuntimeManagedAuth(providerName).oauthRef);
172924
+ }
172572
172925
  async submitFeedback(input, providerName) {
172573
172926
  const auth = this.resolveRuntimeManagedAuth(providerName);
172574
172927
  return this.toolkit.submitFeedback({
@@ -175144,7 +175497,7 @@ var require_command = /* @__PURE__ */ __commonJSMin(((exports) => {
175144
175497
  const EventEmitter$12 = __require("node:events").EventEmitter;
175145
175498
  const childProcess = __require("node:child_process");
175146
175499
  const path$7 = __require("node:path");
175147
- const fs$5 = __require("node:fs");
175500
+ const fs$4 = __require("node:fs");
175148
175501
  const process$2 = __require("node:process");
175149
175502
  const { Argument, humanReadableArgName } = require_argument();
175150
175503
  const { CommanderError } = require_error$2();
@@ -176027,7 +176380,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
176027
176380
  * @param {string} subcommandName
176028
176381
  */
176029
176382
  _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
176030
- if (fs$5.existsSync(executableFile)) return;
176383
+ if (fs$4.existsSync(executableFile)) return;
176031
176384
  const executableMissing = `'${executableFile}' does not exist
176032
176385
  - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
176033
176386
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
@@ -176051,9 +176404,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
176051
176404
  ];
176052
176405
  function findFile(baseDir, baseName) {
176053
176406
  const localBin = path$7.resolve(baseDir, baseName);
176054
- if (fs$5.existsSync(localBin)) return localBin;
176407
+ if (fs$4.existsSync(localBin)) return localBin;
176055
176408
  if (sourceExt.includes(path$7.extname(baseName))) return void 0;
176056
- const foundExt = sourceExt.find((ext) => fs$5.existsSync(`${localBin}${ext}`));
176409
+ const foundExt = sourceExt.find((ext) => fs$4.existsSync(`${localBin}${ext}`));
176057
176410
  if (foundExt) return `${localBin}${foundExt}`;
176058
176411
  }
176059
176412
  this._checkForMissingMandatoryOptions();
@@ -176063,7 +176416,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
176063
176416
  if (this._scriptPath) {
176064
176417
  let resolvedScriptPath;
176065
176418
  try {
176066
- resolvedScriptPath = fs$5.realpathSync(this._scriptPath);
176419
+ resolvedScriptPath = fs$4.realpathSync(this._scriptPath);
176067
176420
  } catch {
176068
176421
  resolvedScriptPath = this._scriptPath;
176069
176422
  }
@@ -184397,7 +184750,7 @@ function optionalBuildString(value) {
184397
184750
  return typeof value === "string" && value.length > 0 ? value : void 0;
184398
184751
  }
184399
184752
  const BLUN_BUILD_INFO = {
184400
- version: optionalBuildString("9.1.651"),
184753
+ version: optionalBuildString("9.1.652"),
184401
184754
  channel: typeof __BLUN_CHANNEL__ === "string" ? optionalBuildString(__BLUN_CHANNEL__) : void 0,
184402
184755
  commit: typeof __BLUN_COMMIT__ === "string" ? optionalBuildString(__BLUN_COMMIT__) : void 0,
184403
184756
  buildTarget: typeof __BLUN_BUILD_TARGET__ === "string" ? optionalBuildString(__BLUN_BUILD_TARGET__) : void 0
@@ -190112,7 +190465,7 @@ var require_atomic_sleep = /* @__PURE__ */ __commonJSMin(((exports, module) => {
190112
190465
  //#endregion
190113
190466
  //#region ../../node_modules/.pnpm/sonic-boom@4.2.1/node_modules/sonic-boom/index.js
190114
190467
  var require_sonic_boom = /* @__PURE__ */ __commonJSMin(((exports, module) => {
190115
- const fs$4 = __require("fs");
190468
+ const fs$3 = __require("fs");
190116
190469
  const EventEmitter$10 = __require("events");
190117
190470
  const inherits$6 = __require("util").inherits;
190118
190471
  const path$6 = __require("path");
@@ -190155,17 +190508,17 @@ var require_sonic_boom = /* @__PURE__ */ __commonJSMin(((exports, module) => {
190155
190508
  const flags = sonic.append ? "a" : "w";
190156
190509
  const mode = sonic.mode;
190157
190510
  if (sonic.sync) try {
190158
- if (sonic.mkdir) fs$4.mkdirSync(path$6.dirname(file), { recursive: true });
190159
- fileOpened(null, fs$4.openSync(file, flags, mode));
190511
+ if (sonic.mkdir) fs$3.mkdirSync(path$6.dirname(file), { recursive: true });
190512
+ fileOpened(null, fs$3.openSync(file, flags, mode));
190160
190513
  } catch (err) {
190161
190514
  fileOpened(err);
190162
190515
  throw err;
190163
190516
  }
190164
- else if (sonic.mkdir) fs$4.mkdir(path$6.dirname(file), { recursive: true }, (err) => {
190517
+ else if (sonic.mkdir) fs$3.mkdir(path$6.dirname(file), { recursive: true }, (err) => {
190165
190518
  if (err) return fileOpened(err);
190166
- fs$4.open(file, flags, mode, fileOpened);
190519
+ fs$3.open(file, flags, mode, fileOpened);
190167
190520
  });
190168
- else fs$4.open(file, flags, mode, fileOpened);
190521
+ else fs$3.open(file, flags, mode, fileOpened);
190169
190522
  }
190170
190523
  function SonicBoom(opts) {
190171
190524
  if (!(this instanceof SonicBoom)) return new SonicBoom(opts);
@@ -190203,8 +190556,8 @@ var require_sonic_boom = /* @__PURE__ */ __commonJSMin(((exports, module) => {
190203
190556
  this.flush = flushBuffer;
190204
190557
  this.flushSync = flushBufferSync;
190205
190558
  this._actualWrite = actualWriteBuffer;
190206
- fsWriteSync = () => fs$4.writeSync(this.fd, this._writingBuf);
190207
- fsWrite = () => fs$4.write(this.fd, this._writingBuf, this.release);
190559
+ fsWriteSync = () => fs$3.writeSync(this.fd, this._writingBuf);
190560
+ fsWrite = () => fs$3.write(this.fd, this._writingBuf, this.release);
190208
190561
  } else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
190209
190562
  this._writingBuf = "";
190210
190563
  this.write = write;
@@ -190212,12 +190565,12 @@ var require_sonic_boom = /* @__PURE__ */ __commonJSMin(((exports, module) => {
190212
190565
  this.flushSync = flushSync;
190213
190566
  this._actualWrite = actualWrite;
190214
190567
  fsWriteSync = () => {
190215
- if (Buffer.isBuffer(this._writingBuf)) return fs$4.writeSync(this.fd, this._writingBuf);
190216
- return fs$4.writeSync(this.fd, this._writingBuf, "utf8");
190568
+ if (Buffer.isBuffer(this._writingBuf)) return fs$3.writeSync(this.fd, this._writingBuf);
190569
+ return fs$3.writeSync(this.fd, this._writingBuf, "utf8");
190217
190570
  };
190218
190571
  fsWrite = () => {
190219
- if (Buffer.isBuffer(this._writingBuf)) return fs$4.write(this.fd, this._writingBuf, this.release);
190220
- return fs$4.write(this.fd, this._writingBuf, "utf8", this.release);
190572
+ if (Buffer.isBuffer(this._writingBuf)) return fs$3.write(this.fd, this._writingBuf, this.release);
190573
+ return fs$3.write(this.fd, this._writingBuf, "utf8", this.release);
190221
190574
  };
190222
190575
  } else throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
190223
190576
  if (typeof fd === "number") {
@@ -190262,7 +190615,7 @@ var require_sonic_boom = /* @__PURE__ */ __commonJSMin(((exports, module) => {
190262
190615
  return;
190263
190616
  }
190264
190617
  }
190265
- if (this._fsync) fs$4.fsyncSync(this.fd);
190618
+ if (this._fsync) fs$3.fsyncSync(this.fd);
190266
190619
  const len = this._len;
190267
190620
  if (this._reopening) {
190268
190621
  this._writing = false;
@@ -190359,7 +190712,7 @@ var require_sonic_boom = /* @__PURE__ */ __commonJSMin(((exports, module) => {
190359
190712
  this._flushPending = true;
190360
190713
  const onDrain = () => {
190361
190714
  if (!this._fsync) try {
190362
- fs$4.fsync(this.fd, (err) => {
190715
+ fs$3.fsync(this.fd, (err) => {
190363
190716
  this._flushPending = false;
190364
190717
  cb(err);
190365
190718
  });
@@ -190436,7 +190789,7 @@ var require_sonic_boom = /* @__PURE__ */ __commonJSMin(((exports, module) => {
190436
190789
  if (this._writing) return;
190437
190790
  const fd = this.fd;
190438
190791
  this.once("ready", () => {
190439
- if (fd !== this.fd) fs$4.close(fd, (err) => {
190792
+ if (fd !== this.fd) fs$3.close(fd, (err) => {
190440
190793
  if (err) return this.emit("error", err);
190441
190794
  });
190442
190795
  });
@@ -190467,7 +190820,7 @@ var require_sonic_boom = /* @__PURE__ */ __commonJSMin(((exports, module) => {
190467
190820
  while (this._bufs.length || buf.length) {
190468
190821
  if (buf.length <= 0) buf = this._bufs[0];
190469
190822
  try {
190470
- const n = Buffer.isBuffer(buf) ? fs$4.writeSync(this.fd, buf) : fs$4.writeSync(this.fd, buf, "utf8");
190823
+ const n = Buffer.isBuffer(buf) ? fs$3.writeSync(this.fd, buf) : fs$3.writeSync(this.fd, buf, "utf8");
190471
190824
  const releasedBufObj = releaseWritingBuf(buf, this._len, n);
190472
190825
  buf = releasedBufObj.writingBuf;
190473
190826
  this._len = releasedBufObj.len;
@@ -190478,7 +190831,7 @@ var require_sonic_boom = /* @__PURE__ */ __commonJSMin(((exports, module) => {
190478
190831
  }
190479
190832
  }
190480
190833
  try {
190481
- fs$4.fsyncSync(this.fd);
190834
+ fs$3.fsyncSync(this.fd);
190482
190835
  } catch {}
190483
190836
  }
190484
190837
  function flushBufferSync() {
@@ -190492,7 +190845,7 @@ var require_sonic_boom = /* @__PURE__ */ __commonJSMin(((exports, module) => {
190492
190845
  while (this._bufs.length || buf.length) {
190493
190846
  if (buf.length <= 0) buf = mergeBuf(this._bufs[0], this._lens[0]);
190494
190847
  try {
190495
- const n = fs$4.writeSync(this.fd, buf);
190848
+ const n = fs$3.writeSync(this.fd, buf);
190496
190849
  buf = buf.subarray(n);
190497
190850
  this._len = Math.max(this._len - n, 0);
190498
190851
  if (buf.length <= 0) {
@@ -190514,24 +190867,24 @@ var require_sonic_boom = /* @__PURE__ */ __commonJSMin(((exports, module) => {
190514
190867
  this._writing = true;
190515
190868
  this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
190516
190869
  if (this.sync) try {
190517
- release(null, Buffer.isBuffer(this._writingBuf) ? fs$4.writeSync(this.fd, this._writingBuf) : fs$4.writeSync(this.fd, this._writingBuf, "utf8"));
190870
+ release(null, Buffer.isBuffer(this._writingBuf) ? fs$3.writeSync(this.fd, this._writingBuf) : fs$3.writeSync(this.fd, this._writingBuf, "utf8"));
190518
190871
  } catch (err) {
190519
190872
  release(err);
190520
190873
  }
190521
- else fs$4.write(this.fd, this._writingBuf, release);
190874
+ else fs$3.write(this.fd, this._writingBuf, release);
190522
190875
  }
190523
190876
  function actualWriteBuffer() {
190524
190877
  const release = this.release;
190525
190878
  this._writing = true;
190526
190879
  this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift());
190527
190880
  if (this.sync) try {
190528
- release(null, fs$4.writeSync(this.fd, this._writingBuf));
190881
+ release(null, fs$3.writeSync(this.fd, this._writingBuf));
190529
190882
  } catch (err) {
190530
190883
  release(err);
190531
190884
  }
190532
190885
  else {
190533
190886
  if (kCopyBuffer) this._writingBuf = Buffer.from(this._writingBuf);
190534
- fs$4.write(this.fd, this._writingBuf, release);
190887
+ fs$3.write(this.fd, this._writingBuf, release);
190535
190888
  }
190536
190889
  }
190537
190890
  function actualClose(sonic) {
@@ -190545,10 +190898,10 @@ var require_sonic_boom = /* @__PURE__ */ __commonJSMin(((exports, module) => {
190545
190898
  sonic._lens = [];
190546
190899
  assert$8(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
190547
190900
  try {
190548
- fs$4.fsync(sonic.fd, closeWrapped);
190901
+ fs$3.fsync(sonic.fd, closeWrapped);
190549
190902
  } catch {}
190550
190903
  function closeWrapped() {
190551
- if (sonic.fd !== 1 && sonic.fd !== 2) fs$4.close(sonic.fd, done);
190904
+ if (sonic.fd !== 1 && sonic.fd !== 2) fs$3.close(sonic.fd, done);
190552
190905
  else done();
190553
190906
  }
190554
190907
  function done(err) {
@@ -214472,7 +214825,7 @@ var require_constants$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
214472
214825
  //#endregion
214473
214826
  //#region ../../../../../node_modules/node-gyp-build/node-gyp-build.js
214474
214827
  var require_node_gyp_build$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
214475
- var fs$3 = __require("fs");
214828
+ var fs$2 = __require("fs");
214476
214829
  var path$5 = __require("path");
214477
214830
  var os$3 = __require("os");
214478
214831
  var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
@@ -214528,7 +214881,7 @@ var require_node_gyp_build$1 = /* @__PURE__ */ __commonJSMin(((exports, module)
214528
214881
  };
214529
214882
  function readdirSync(dir) {
214530
214883
  try {
214531
- return fs$3.readdirSync(dir);
214884
+ return fs$2.readdirSync(dir);
214532
214885
  } catch (err) {
214533
214886
  return [];
214534
214887
  }
@@ -214616,7 +214969,7 @@ var require_node_gyp_build$1 = /* @__PURE__ */ __commonJSMin(((exports, module)
214616
214969
  return typeof window !== "undefined" && window.process && window.process.type === "renderer";
214617
214970
  }
214618
214971
  function isAlpine(platform) {
214619
- return platform === "linux" && fs$3.existsSync("/etc/alpine-release");
214972
+ return platform === "linux" && fs$2.existsSync("/etc/alpine-release");
214620
214973
  }
214621
214974
  load.parseTags = parseTags;
214622
214975
  load.matchTags = matchTags;
@@ -234729,7 +235082,7 @@ var require_dist$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
234729
235082
  //#region ../../node_modules/.pnpm/@fastify+swagger@9.7.0/node_modules/@fastify/swagger/lib/mode/static.js
234730
235083
  var require_static = /* @__PURE__ */ __commonJSMin(((exports, module) => {
234731
235084
  const path$3 = __require("node:path");
234732
- const fs$2 = __require("node:fs");
235085
+ const fs$1 = __require("node:fs");
234733
235086
  const yaml = require_dist$1();
234734
235087
  module.exports = function(fastify, opts, done) {
234735
235088
  if (!opts.specification) return done(/* @__PURE__ */ new Error("specification is missing in the module options"));
@@ -234738,14 +235091,14 @@ var require_static = /* @__PURE__ */ __commonJSMin(((exports, module) => {
234738
235091
  if (!opts.specification.path && !opts.specification.document) return done(/* @__PURE__ */ new Error("both specification.path and specification.document are missing, should be path to the file or swagger document spec"));
234739
235092
  else if (opts.specification.path) {
234740
235093
  if (typeof opts.specification.path !== "string") return done(/* @__PURE__ */ new Error("specification.path is not a string"));
234741
- if (!fs$2.existsSync(path$3.resolve(opts.specification.path))) return done(/* @__PURE__ */ new Error(`${opts.specification.path} does not exist`));
235094
+ if (!fs$1.existsSync(path$3.resolve(opts.specification.path))) return done(/* @__PURE__ */ new Error(`${opts.specification.path} does not exist`));
234742
235095
  const extName = path$3.extname(opts.specification.path).toLowerCase();
234743
235096
  if ([".yaml", ".json"].indexOf(extName) === -1) return done(/* @__PURE__ */ new Error("specification.path extension name is not supported, should be one from ['.yaml', '.json']"));
234744
235097
  if (opts.specification.postProcessor && typeof opts.specification.postProcessor !== "function") return done(/* @__PURE__ */ new Error("specification.postProcessor should be a function"));
234745
235098
  if (opts.specification.baseDir && typeof opts.specification.baseDir !== "string") return done(/* @__PURE__ */ new Error("specification.baseDir should be string"));
234746
235099
  if (!opts.specification.baseDir) opts.specification.baseDir = path$3.resolve(path$3.dirname(opts.specification.path));
234747
235100
  else while (opts.specification.baseDir.endsWith("/")) opts.specification.baseDir = opts.specification.baseDir.slice(0, -1);
234748
- const source = fs$2.readFileSync(path$3.resolve(opts.specification.path), "utf8");
235101
+ const source = fs$1.readFileSync(path$3.resolve(opts.specification.path), "utf8");
234749
235102
  switch (extName) {
234750
235103
  case ".yaml":
234751
235104
  swaggerObject = yaml.parse(source);
@@ -235012,11 +235365,11 @@ var require_should_route_hide = /* @__PURE__ */ __commonJSMin(((exports, module)
235012
235365
  //#endregion
235013
235366
  //#region ../../node_modules/.pnpm/@fastify+swagger@9.7.0/node_modules/@fastify/swagger/lib/util/read-package-json.js
235014
235367
  var require_read_package_json = /* @__PURE__ */ __commonJSMin(((exports, module) => {
235015
- const fs$1 = __require("node:fs");
235368
+ const fs = __require("node:fs");
235016
235369
  const path$2 = __require("node:path");
235017
235370
  function readPackageJson() {
235018
235371
  try {
235019
- return JSON.parse(fs$1.readFileSync(path$2.join(__dirname, "..", "..", "package.json")));
235372
+ return JSON.parse(fs.readFileSync(path$2.join(__dirname, "..", "..", "package.json")));
235020
235373
  } catch {
235021
235374
  return {};
235022
235375
  }
@@ -247780,7 +248133,7 @@ var TUI = class TUI extends Container {
247780
248133
  if (!debugRedraw) return;
247781
248134
  const logPath = path$16.join(nodeOs.homedir(), ".pi", "agent", "pi-debug.log");
247782
248135
  const msg = `[${(/* @__PURE__ */ new Date()).toISOString()}] fullRender: ${reason} (prev=${this.previousLines.length}, new=${newLines.length}, height=${height})\n`;
247783
- fs$17.appendFileSync(logPath, msg);
248136
+ fs$16.appendFileSync(logPath, msg);
247784
248137
  };
247785
248138
  if (this.previousLines.length === 0 && !widthChanged && !heightChanged) {
247786
248139
  logRedraw("first render");
@@ -247927,7 +248280,7 @@ var TUI = class TUI extends Container {
247927
248280
  buffer += "\x1B[?2026l";
247928
248281
  if (process.env["PI_TUI_DEBUG"] === "1") {
247929
248282
  const debugDir = "/tmp/tui";
247930
- fs$17.mkdirSync(debugDir, { recursive: true });
248283
+ fs$16.mkdirSync(debugDir, { recursive: true });
247931
248284
  const debugPath = path$16.join(debugDir, `render-${Date.now()}-${Math.random().toString(36).slice(2)}.log`);
247932
248285
  const debugData = [
247933
248286
  `firstChanged: ${firstChanged}`,
@@ -247951,7 +248304,7 @@ var TUI = class TUI extends Container {
247951
248304
  "=== buffer ===",
247952
248305
  JSON.stringify(buffer)
247953
248306
  ].join("\n");
247954
- fs$17.writeFileSync(debugPath, debugData);
248307
+ fs$16.writeFileSync(debugPath, debugData);
247955
248308
  }
247956
248309
  this.terminal.write(buffer);
247957
248310
  this.cursorRow = Math.max(0, newLines.length - 1);
@@ -252608,7 +252961,7 @@ var ProcessTerminal = class {
252608
252961
  const env = process.env["PI_TUI_WRITE_LOG"] || "";
252609
252962
  if (!env) return "";
252610
252963
  try {
252611
- if (fs$17.statSync(env).isDirectory()) {
252964
+ if (fs$16.statSync(env).isDirectory()) {
252612
252965
  const now = /* @__PURE__ */ new Date();
252613
252966
  const ts = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}_${String(now.getHours()).padStart(2, "0")}-${String(now.getMinutes()).padStart(2, "0")}-${String(now.getSeconds()).padStart(2, "0")}`;
252614
252967
  return path$16.join(env, `tui-${ts}-${process.pid}.log`);
@@ -252891,7 +253244,7 @@ var ProcessTerminal = class {
252891
253244
  write(data) {
252892
253245
  process.stdout.write(data);
252893
253246
  if (this.writeLogPath) try {
252894
- fs$17.appendFileSync(this.writeLogPath, data, { encoding: "utf8" });
253247
+ fs$16.appendFileSync(this.writeLogPath, data, { encoding: "utf8" });
252895
253248
  } catch {}
252896
253249
  }
252897
253250
  get columns() {
@@ -255913,7 +256266,7 @@ async function loadManagedUsageReport(host) {
255913
256266
  } catch (error) {
255914
256267
  return { error: formatErrorMessage$2(error) };
255915
256268
  }
255916
- if (res.kind === "error") return { error: res.message };
256269
+ if (res.kind === "error") return { error: res.message ?? (res.code === "unauthenticated" ? "Sign in to view account usage." : "Account usage is unavailable.") };
255917
256270
  return { usage: {
255918
256271
  summary: res.summary,
255919
256272
  limits: res.limits