claudish 7.17.0 → 7.18.0

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.
Files changed (2) hide show
  1. package/dist/index.js +321 -642
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -460,6 +460,69 @@ var require_main = __commonJS((exports, module) => {
460
460
  module.exports = DotenvModule;
461
461
  });
462
462
 
463
+ // src/config-override.ts
464
+ var exports_config_override = {};
465
+ __export(exports_config_override, {
466
+ setConfigFileOverride: () => setConfigFileOverride,
467
+ planConfigOverride: () => planConfigOverride,
468
+ getConfigFileOverride: () => getConfigFileOverride,
469
+ activeOpConfigPaths: () => activeOpConfigPaths,
470
+ activeGlobalConfigFile: () => activeGlobalConfigFile
471
+ });
472
+ function setConfigFileOverride(path) {
473
+ overridePath = path;
474
+ }
475
+ function getConfigFileOverride() {
476
+ return overridePath;
477
+ }
478
+ function activeGlobalConfigFile(realGlobal) {
479
+ return overridePath ?? realGlobal;
480
+ }
481
+ function activeOpConfigPaths(defaults) {
482
+ if (overridePath === null)
483
+ return defaults;
484
+ const file = overridePath;
485
+ return {
486
+ global: () => file,
487
+ project: () => SUPPRESSED_PROJECT_CONFIG
488
+ };
489
+ }
490
+ function planConfigOverride(argv, env, deps) {
491
+ const flag = scanConfigFlag(argv);
492
+ let path;
493
+ if (flag) {
494
+ if (!flag.value || flag.value.startsWith("-")) {
495
+ return { kind: "error", message: "[claudish] --config requires a file path" };
496
+ }
497
+ path = flag.value;
498
+ } else {
499
+ path = env.CLAUDISH_CONFIG || undefined;
500
+ }
501
+ if (!path)
502
+ return { kind: "none" };
503
+ const resolved = deps.resolve(path);
504
+ if (!deps.exists(resolved)) {
505
+ return { kind: "error", message: `[claudish] --config file not found: ${resolved}` };
506
+ }
507
+ const rest = argv.slice();
508
+ if (flag)
509
+ rest.splice(flag.dropAt, flag.dropCount);
510
+ return { kind: "apply", path: resolved, argv: rest, fromFlag: flag !== null };
511
+ }
512
+ function scanConfigFlag(argv) {
513
+ for (let i = 0;i < argv.length; i++) {
514
+ const a = argv[i];
515
+ if (a === "--config") {
516
+ return { value: argv[i + 1], dropAt: i, dropCount: argv[i + 1] === undefined ? 1 : 2 };
517
+ }
518
+ if (a.startsWith("--config=")) {
519
+ return { value: a.slice("--config=".length), dropAt: i, dropCount: 1 };
520
+ }
521
+ }
522
+ return null;
523
+ }
524
+ var SUPPRESSED_PROJECT_CONFIG = "", overridePath = null;
525
+
463
526
  // src/providers/onepassword-config.ts
464
527
  import { existsSync, readFileSync, writeFileSync } from "fs";
465
528
  import { homedir } from "os";
@@ -482,6 +545,9 @@ function readRawConfig(path) {
482
545
  }
483
546
  function mutateConfig(scope, paths, mutate) {
484
547
  const path = pathFor(scope, paths);
548
+ if (path === "") {
549
+ throw new Error("Cannot save to project scope while --config/CLAUDISH_CONFIG is active \u2014 " + "the override file is the only config for this run. Save to global scope " + "(which writes to the override file), or re-run without --config.");
550
+ }
485
551
  const cfg = readRawConfig(path);
486
552
  mutate(cfg);
487
553
  writeFileSync(path, `${JSON.stringify(cfg, null, 2)}
@@ -572,16 +638,20 @@ function addOnepasswordEnvironment(id, scope, paths = defaultOpConfigPaths) {
572
638
  function removeOnepasswordEnvironment(id, scope, paths = defaultOpConfigPaths) {
573
639
  removeFromStringList(scope, "onepasswordEnvironments", id, paths);
574
640
  }
575
- var defaultOpConfigPaths;
641
+ var realOpConfigPaths, defaultOpConfigPaths;
576
642
  var init_onepassword_config = __esm(() => {
577
- defaultOpConfigPaths = {
643
+ realOpConfigPaths = {
578
644
  global: () => join(homedir(), ".claudish", "config.json"),
579
645
  project: () => join(process.cwd(), ".claudish.json")
580
646
  };
647
+ defaultOpConfigPaths = {
648
+ global: () => activeOpConfigPaths(realOpConfigPaths).global(),
649
+ project: () => activeOpConfigPaths(realOpConfigPaths).project()
650
+ };
581
651
  });
582
652
 
583
653
  // src/version.ts
584
- var VERSION = "7.17.0";
654
+ var VERSION = "7.18.0";
585
655
 
586
656
  // src/logger.ts
587
657
  var exports_logger = {};
@@ -3942,6 +4012,8 @@ function resetSdkClientCache() {
3942
4012
  }
3943
4013
  function isTransientSdkError(err) {
3944
4014
  const msg = (err instanceof Error ? err.message : String(err)).toLowerCase();
4015
+ if (msg.includes("denied authorization"))
4016
+ return false;
3945
4017
  return msg.includes("ipc operation failed") || msg.includes("ipc operation") || msg.includes("-4") || msg.includes("denied") || msg.includes("broken pipe") || msg.includes("connection") || msg.includes("invalid client id") || msg.includes("invalid client") || msg.includes("invalid session") || msg.includes("session expired") || msg.includes("session not found") || msg.includes("unauthorized") || msg.includes("token expired") || msg.includes("not authenticated");
3946
4018
  }
3947
4019
  function runSdkExclusive(op, label = "op:sdk-op", meta) {
@@ -4285,7 +4357,7 @@ function readConfigRaw() {
4285
4357
  if (testSeams?.config)
4286
4358
  return testSeams.config;
4287
4359
  try {
4288
- const configPath = join5(homedir5(), ".claudish", "config.json");
4360
+ const configPath = activeGlobalConfigFile(join5(homedir5(), ".claudish", "config.json"));
4289
4361
  if (!existsSync4(configPath))
4290
4362
  return {};
4291
4363
  return JSON.parse(readFileSync3(configPath, "utf-8"));
@@ -27498,6 +27570,7 @@ __export(exports_profile_config, {
27498
27570
  setProfile: () => setProfile,
27499
27571
  setEndpoint: () => setEndpoint,
27500
27572
  setDefaultProfile: () => setDefaultProfile,
27573
+ setConfigFileOverride: () => setConfigFileOverride,
27501
27574
  setApiKey: () => setApiKey,
27502
27575
  saveLocalConfig: () => saveLocalConfig,
27503
27576
  saveConfig: () => saveConfig,
@@ -27524,23 +27597,29 @@ __export(exports_profile_config, {
27524
27597
  deleteProfile: () => deleteProfile,
27525
27598
  createProfile: () => createProfile,
27526
27599
  configExistsForScope: () => configExistsForScope,
27527
- configExists: () => configExists
27600
+ configExists: () => configExists,
27601
+ activeConfigFile: () => activeConfigFile
27528
27602
  });
27529
27603
  import { existsSync as existsSync6, mkdirSync as mkdirSync6, readFileSync as readFileSync5, writeFileSync as writeFileSync7 } from "fs";
27530
27604
  import { homedir as homedir8 } from "os";
27531
27605
  import { dirname as dirname3, join as join8, parse as parse6 } from "path";
27606
+ function activeConfigFile() {
27607
+ return activeGlobalConfigFile(CONFIG_FILE);
27608
+ }
27532
27609
  function ensureConfigDir() {
27533
27610
  if (!existsSync6(CONFIG_DIR)) {
27534
27611
  mkdirSync6(CONFIG_DIR, { recursive: true });
27535
27612
  }
27536
27613
  }
27537
27614
  function loadConfig() {
27538
- ensureConfigDir();
27539
- if (!existsSync6(CONFIG_FILE)) {
27615
+ const activeFile = activeConfigFile();
27616
+ if (!getConfigFileOverride())
27617
+ ensureConfigDir();
27618
+ if (!existsSync6(activeFile)) {
27540
27619
  return { ...DEFAULT_CONFIG };
27541
27620
  }
27542
27621
  try {
27543
- const content = readFileSync5(CONFIG_FILE, "utf-8");
27622
+ const content = readFileSync5(activeFile, "utf-8");
27544
27623
  const config2 = JSON.parse(content);
27545
27624
  const merged = {
27546
27625
  version: config2.version || DEFAULT_CONFIG.version,
@@ -27593,8 +27672,9 @@ function loadConfig() {
27593
27672
  }
27594
27673
  }
27595
27674
  function saveConfig(config2) {
27596
- ensureConfigDir();
27597
- writeFileSync7(CONFIG_FILE, JSON.stringify(config2, null, 2), "utf-8");
27675
+ if (!getConfigFileOverride())
27676
+ ensureConfigDir();
27677
+ writeFileSync7(activeConfigFile(), JSON.stringify(config2, null, 2), "utf-8");
27598
27678
  }
27599
27679
  function configExists() {
27600
27680
  return existsSync6(CONFIG_FILE);
@@ -27625,6 +27705,8 @@ function isProjectDirectory() {
27625
27705
  return [".git", "package.json", "Cargo.toml", "go.mod", "pyproject.toml", ".claudish.json"].some((f) => existsSync6(join8(cwd, f)));
27626
27706
  }
27627
27707
  function loadLocalConfig() {
27708
+ if (getConfigFileOverride())
27709
+ return null;
27628
27710
  const localPath = getLocalConfigPath();
27629
27711
  if (!existsSync6(localPath)) {
27630
27712
  return null;
@@ -28615,535 +28697,6 @@ var init_provider_definitions = __esm(() => {
28615
28697
  ];
28616
28698
  });
28617
28699
 
28618
- // ../../node_modules/.bun/@hono+node-server@1.19.6+86bafc9754e56507/node_modules/@hono/node-server/dist/index.mjs
28619
- import { createServer as createServerHTTP } from "http";
28620
- import { Http2ServerRequest as Http2ServerRequest2 } from "http2";
28621
- import { Http2ServerRequest } from "http2";
28622
- import { Readable } from "stream";
28623
- import crypto from "crypto";
28624
- async function readWithoutBlocking(readPromise) {
28625
- return Promise.race([readPromise, Promise.resolve().then(() => Promise.resolve(undefined))]);
28626
- }
28627
- function writeFromReadableStreamDefaultReader(reader, writable, currentReadPromise) {
28628
- const cancel = (error46) => {
28629
- reader.cancel(error46).catch(() => {});
28630
- };
28631
- writable.on("close", cancel);
28632
- writable.on("error", cancel);
28633
- (currentReadPromise ?? reader.read()).then(flow, handleStreamError);
28634
- return reader.closed.finally(() => {
28635
- writable.off("close", cancel);
28636
- writable.off("error", cancel);
28637
- });
28638
- function handleStreamError(error46) {
28639
- if (error46) {
28640
- writable.destroy(error46);
28641
- }
28642
- }
28643
- function onDrain() {
28644
- reader.read().then(flow, handleStreamError);
28645
- }
28646
- function flow({ done, value }) {
28647
- try {
28648
- if (done) {
28649
- writable.end();
28650
- } else if (!writable.write(value)) {
28651
- writable.once("drain", onDrain);
28652
- } else {
28653
- return reader.read().then(flow, handleStreamError);
28654
- }
28655
- } catch (e) {
28656
- handleStreamError(e);
28657
- }
28658
- }
28659
- }
28660
- function writeFromReadableStream(stream, writable) {
28661
- if (stream.locked) {
28662
- throw new TypeError("ReadableStream is locked.");
28663
- } else if (writable.destroyed) {
28664
- return;
28665
- }
28666
- return writeFromReadableStreamDefaultReader(stream.getReader(), writable);
28667
- }
28668
- var RequestError, toRequestError = (e) => {
28669
- if (e instanceof RequestError) {
28670
- return e;
28671
- }
28672
- return new RequestError(e.message, { cause: e });
28673
- }, GlobalRequest, Request2, newHeadersFromIncoming = (incoming) => {
28674
- const headerRecord = [];
28675
- const rawHeaders = incoming.rawHeaders;
28676
- for (let i = 0;i < rawHeaders.length; i += 2) {
28677
- const { [i]: key, [i + 1]: value } = rawHeaders;
28678
- if (key.charCodeAt(0) !== 58) {
28679
- headerRecord.push([key, value]);
28680
- }
28681
- }
28682
- return new Headers(headerRecord);
28683
- }, wrapBodyStream, newRequestFromIncoming = (method, url2, headers, incoming, abortController) => {
28684
- const init = {
28685
- method,
28686
- headers,
28687
- signal: abortController.signal
28688
- };
28689
- if (method === "TRACE") {
28690
- init.method = "GET";
28691
- const req = new Request2(url2, init);
28692
- Object.defineProperty(req, "method", {
28693
- get() {
28694
- return "TRACE";
28695
- }
28696
- });
28697
- return req;
28698
- }
28699
- if (!(method === "GET" || method === "HEAD")) {
28700
- if ("rawBody" in incoming && incoming.rawBody instanceof Buffer) {
28701
- init.body = new ReadableStream({
28702
- start(controller) {
28703
- controller.enqueue(incoming.rawBody);
28704
- controller.close();
28705
- }
28706
- });
28707
- } else if (incoming[wrapBodyStream]) {
28708
- let reader;
28709
- init.body = new ReadableStream({
28710
- async pull(controller) {
28711
- try {
28712
- reader ||= Readable.toWeb(incoming).getReader();
28713
- const { done, value } = await reader.read();
28714
- if (done) {
28715
- controller.close();
28716
- } else {
28717
- controller.enqueue(value);
28718
- }
28719
- } catch (error46) {
28720
- controller.error(error46);
28721
- }
28722
- }
28723
- });
28724
- } else {
28725
- init.body = Readable.toWeb(incoming);
28726
- }
28727
- }
28728
- return new Request2(url2, init);
28729
- }, getRequestCache, requestCache, incomingKey, urlKey, headersKey, abortControllerKey, getAbortController, requestPrototype, newRequest = (incoming, defaultHostname) => {
28730
- const req = Object.create(requestPrototype);
28731
- req[incomingKey] = incoming;
28732
- const incomingUrl = incoming.url || "";
28733
- if (incomingUrl[0] !== "/" && (incomingUrl.startsWith("http://") || incomingUrl.startsWith("https://"))) {
28734
- if (incoming instanceof Http2ServerRequest) {
28735
- throw new RequestError("Absolute URL for :path is not allowed in HTTP/2");
28736
- }
28737
- try {
28738
- const url22 = new URL(incomingUrl);
28739
- req[urlKey] = url22.href;
28740
- } catch (e) {
28741
- throw new RequestError("Invalid absolute URL", { cause: e });
28742
- }
28743
- return req;
28744
- }
28745
- const host = (incoming instanceof Http2ServerRequest ? incoming.authority : incoming.headers.host) || defaultHostname;
28746
- if (!host) {
28747
- throw new RequestError("Missing host header");
28748
- }
28749
- let scheme;
28750
- if (incoming instanceof Http2ServerRequest) {
28751
- scheme = incoming.scheme;
28752
- if (!(scheme === "http" || scheme === "https")) {
28753
- throw new RequestError("Unsupported scheme");
28754
- }
28755
- } else {
28756
- scheme = incoming.socket && incoming.socket.encrypted ? "https" : "http";
28757
- }
28758
- const url2 = new URL(`${scheme}://${host}${incomingUrl}`);
28759
- if (url2.hostname.length !== host.length && url2.hostname !== host.replace(/:\d+$/, "")) {
28760
- throw new RequestError("Invalid host header");
28761
- }
28762
- req[urlKey] = url2.href;
28763
- return req;
28764
- }, responseCache, getResponseCache, cacheKey, GlobalResponse, Response2, buildOutgoingHttpHeaders = (headers) => {
28765
- const res = {};
28766
- if (!(headers instanceof Headers)) {
28767
- headers = new Headers(headers ?? undefined);
28768
- }
28769
- const cookies = [];
28770
- for (const [k, v] of headers) {
28771
- if (k === "set-cookie") {
28772
- cookies.push(v);
28773
- } else {
28774
- res[k] = v;
28775
- }
28776
- }
28777
- if (cookies.length > 0) {
28778
- res["set-cookie"] = cookies;
28779
- }
28780
- res["content-type"] ??= "text/plain; charset=UTF-8";
28781
- return res;
28782
- }, X_ALREADY_SENT = "x-hono-already-sent", webFetch, outgoingEnded, handleRequestError = () => new Response(null, {
28783
- status: 400
28784
- }), handleFetchError = (e) => new Response(null, {
28785
- status: e instanceof Error && (e.name === "TimeoutError" || e.constructor.name === "TimeoutError") ? 504 : 500
28786
- }), handleResponseError = (e, outgoing) => {
28787
- const err = e instanceof Error ? e : new Error("unknown error", { cause: e });
28788
- if (err.code === "ERR_STREAM_PREMATURE_CLOSE") {
28789
- console.info("The user aborted a request.");
28790
- } else {
28791
- console.error(e);
28792
- if (!outgoing.headersSent) {
28793
- outgoing.writeHead(500, { "Content-Type": "text/plain" });
28794
- }
28795
- outgoing.end(`Error: ${err.message}`);
28796
- outgoing.destroy(err);
28797
- }
28798
- }, flushHeaders = (outgoing) => {
28799
- if ("flushHeaders" in outgoing && outgoing.writable) {
28800
- outgoing.flushHeaders();
28801
- }
28802
- }, responseViaCache = async (res, outgoing) => {
28803
- let [status, body, header] = res[cacheKey];
28804
- if (header instanceof Headers) {
28805
- header = buildOutgoingHttpHeaders(header);
28806
- }
28807
- if (typeof body === "string") {
28808
- header["Content-Length"] = Buffer.byteLength(body);
28809
- } else if (body instanceof Uint8Array) {
28810
- header["Content-Length"] = body.byteLength;
28811
- } else if (body instanceof Blob) {
28812
- header["Content-Length"] = body.size;
28813
- }
28814
- outgoing.writeHead(status, header);
28815
- if (typeof body === "string" || body instanceof Uint8Array) {
28816
- outgoing.end(body);
28817
- } else if (body instanceof Blob) {
28818
- outgoing.end(new Uint8Array(await body.arrayBuffer()));
28819
- } else {
28820
- flushHeaders(outgoing);
28821
- await writeFromReadableStream(body, outgoing)?.catch((e) => handleResponseError(e, outgoing));
28822
- }
28823
- outgoing[outgoingEnded]?.();
28824
- }, isPromise = (res) => typeof res.then === "function", responseViaResponseObject = async (res, outgoing, options = {}) => {
28825
- if (isPromise(res)) {
28826
- if (options.errorHandler) {
28827
- try {
28828
- res = await res;
28829
- } catch (err) {
28830
- const errRes = await options.errorHandler(err);
28831
- if (!errRes) {
28832
- return;
28833
- }
28834
- res = errRes;
28835
- }
28836
- } else {
28837
- res = await res.catch(handleFetchError);
28838
- }
28839
- }
28840
- if (cacheKey in res) {
28841
- return responseViaCache(res, outgoing);
28842
- }
28843
- const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
28844
- if (res.body) {
28845
- const reader = res.body.getReader();
28846
- const values = [];
28847
- let done = false;
28848
- let currentReadPromise = undefined;
28849
- if (resHeaderRecord["transfer-encoding"] !== "chunked") {
28850
- let maxReadCount = 2;
28851
- for (let i = 0;i < maxReadCount; i++) {
28852
- currentReadPromise ||= reader.read();
28853
- const chunk = await readWithoutBlocking(currentReadPromise).catch((e) => {
28854
- console.error(e);
28855
- done = true;
28856
- });
28857
- if (!chunk) {
28858
- if (i === 1) {
28859
- await new Promise((resolve) => setTimeout(resolve));
28860
- maxReadCount = 3;
28861
- continue;
28862
- }
28863
- break;
28864
- }
28865
- currentReadPromise = undefined;
28866
- if (chunk.value) {
28867
- values.push(chunk.value);
28868
- }
28869
- if (chunk.done) {
28870
- done = true;
28871
- break;
28872
- }
28873
- }
28874
- if (done && !("content-length" in resHeaderRecord)) {
28875
- resHeaderRecord["content-length"] = values.reduce((acc, value) => acc + value.length, 0);
28876
- }
28877
- }
28878
- outgoing.writeHead(res.status, resHeaderRecord);
28879
- values.forEach((value) => {
28880
- outgoing.write(value);
28881
- });
28882
- if (done) {
28883
- outgoing.end();
28884
- } else {
28885
- if (values.length === 0) {
28886
- flushHeaders(outgoing);
28887
- }
28888
- await writeFromReadableStreamDefaultReader(reader, outgoing, currentReadPromise);
28889
- }
28890
- } else if (resHeaderRecord[X_ALREADY_SENT]) {} else {
28891
- outgoing.writeHead(res.status, resHeaderRecord);
28892
- outgoing.end();
28893
- }
28894
- outgoing[outgoingEnded]?.();
28895
- }, getRequestListener = (fetchCallback, options = {}) => {
28896
- const autoCleanupIncoming = options.autoCleanupIncoming ?? true;
28897
- if (options.overrideGlobalObjects !== false && global.Request !== Request2) {
28898
- Object.defineProperty(global, "Request", {
28899
- value: Request2
28900
- });
28901
- Object.defineProperty(global, "Response", {
28902
- value: Response2
28903
- });
28904
- }
28905
- return async (incoming, outgoing) => {
28906
- let res, req;
28907
- try {
28908
- req = newRequest(incoming, options.hostname);
28909
- let incomingEnded = !autoCleanupIncoming || incoming.method === "GET" || incoming.method === "HEAD";
28910
- if (!incomingEnded) {
28911
- incoming[wrapBodyStream] = true;
28912
- incoming.on("end", () => {
28913
- incomingEnded = true;
28914
- });
28915
- if (incoming instanceof Http2ServerRequest2) {
28916
- outgoing[outgoingEnded] = () => {
28917
- if (!incomingEnded) {
28918
- setTimeout(() => {
28919
- if (!incomingEnded) {
28920
- setTimeout(() => {
28921
- incoming.destroy();
28922
- outgoing.destroy();
28923
- });
28924
- }
28925
- });
28926
- }
28927
- };
28928
- }
28929
- }
28930
- outgoing.on("close", () => {
28931
- const abortController = req[abortControllerKey];
28932
- if (abortController) {
28933
- if (incoming.errored) {
28934
- req[abortControllerKey].abort(incoming.errored.toString());
28935
- } else if (!outgoing.writableFinished) {
28936
- req[abortControllerKey].abort("Client connection prematurely closed.");
28937
- }
28938
- }
28939
- if (!incomingEnded) {
28940
- setTimeout(() => {
28941
- if (!incomingEnded) {
28942
- setTimeout(() => {
28943
- incoming.destroy();
28944
- });
28945
- }
28946
- });
28947
- }
28948
- });
28949
- res = fetchCallback(req, { incoming, outgoing });
28950
- if (cacheKey in res) {
28951
- return responseViaCache(res, outgoing);
28952
- }
28953
- } catch (e) {
28954
- if (!res) {
28955
- if (options.errorHandler) {
28956
- res = await options.errorHandler(req ? e : toRequestError(e));
28957
- if (!res) {
28958
- return;
28959
- }
28960
- } else if (!req) {
28961
- res = handleRequestError();
28962
- } else {
28963
- res = handleFetchError(e);
28964
- }
28965
- } else {
28966
- return handleResponseError(e, outgoing);
28967
- }
28968
- }
28969
- try {
28970
- return await responseViaResponseObject(res, outgoing, options);
28971
- } catch (e) {
28972
- return handleResponseError(e, outgoing);
28973
- }
28974
- };
28975
- }, createAdaptorServer = (options) => {
28976
- const fetchCallback = options.fetch;
28977
- const requestListener = getRequestListener(fetchCallback, {
28978
- hostname: options.hostname,
28979
- overrideGlobalObjects: options.overrideGlobalObjects,
28980
- autoCleanupIncoming: options.autoCleanupIncoming
28981
- });
28982
- const createServer2 = options.createServer || createServerHTTP;
28983
- const server = createServer2(options.serverOptions || {}, requestListener);
28984
- return server;
28985
- }, serve = (options, listeningListener) => {
28986
- const server = createAdaptorServer(options);
28987
- server.listen(options?.port ?? 3000, options.hostname, () => {
28988
- const serverInfo = server.address();
28989
- listeningListener && listeningListener(serverInfo);
28990
- });
28991
- return server;
28992
- };
28993
- var init_dist = __esm(() => {
28994
- RequestError = class extends Error {
28995
- constructor(message, options) {
28996
- super(message, options);
28997
- this.name = "RequestError";
28998
- }
28999
- };
29000
- GlobalRequest = global.Request;
29001
- Request2 = class extends GlobalRequest {
29002
- constructor(input, options) {
29003
- if (typeof input === "object" && getRequestCache in input) {
29004
- input = input[getRequestCache]();
29005
- }
29006
- if (typeof options?.body?.getReader !== "undefined") {
29007
- options.duplex ??= "half";
29008
- }
29009
- super(input, options);
29010
- }
29011
- };
29012
- wrapBodyStream = Symbol("wrapBodyStream");
29013
- getRequestCache = Symbol("getRequestCache");
29014
- requestCache = Symbol("requestCache");
29015
- incomingKey = Symbol("incomingKey");
29016
- urlKey = Symbol("urlKey");
29017
- headersKey = Symbol("headersKey");
29018
- abortControllerKey = Symbol("abortControllerKey");
29019
- getAbortController = Symbol("getAbortController");
29020
- requestPrototype = {
29021
- get method() {
29022
- return this[incomingKey].method || "GET";
29023
- },
29024
- get url() {
29025
- return this[urlKey];
29026
- },
29027
- get headers() {
29028
- return this[headersKey] ||= newHeadersFromIncoming(this[incomingKey]);
29029
- },
29030
- [getAbortController]() {
29031
- this[getRequestCache]();
29032
- return this[abortControllerKey];
29033
- },
29034
- [getRequestCache]() {
29035
- this[abortControllerKey] ||= new AbortController;
29036
- return this[requestCache] ||= newRequestFromIncoming(this.method, this[urlKey], this.headers, this[incomingKey], this[abortControllerKey]);
29037
- }
29038
- };
29039
- [
29040
- "body",
29041
- "bodyUsed",
29042
- "cache",
29043
- "credentials",
29044
- "destination",
29045
- "integrity",
29046
- "mode",
29047
- "redirect",
29048
- "referrer",
29049
- "referrerPolicy",
29050
- "signal",
29051
- "keepalive"
29052
- ].forEach((k) => {
29053
- Object.defineProperty(requestPrototype, k, {
29054
- get() {
29055
- return this[getRequestCache]()[k];
29056
- }
29057
- });
29058
- });
29059
- ["arrayBuffer", "blob", "clone", "formData", "json", "text"].forEach((k) => {
29060
- Object.defineProperty(requestPrototype, k, {
29061
- value: function() {
29062
- return this[getRequestCache]()[k]();
29063
- }
29064
- });
29065
- });
29066
- Object.setPrototypeOf(requestPrototype, Request2.prototype);
29067
- responseCache = Symbol("responseCache");
29068
- getResponseCache = Symbol("getResponseCache");
29069
- cacheKey = Symbol("cache");
29070
- GlobalResponse = global.Response;
29071
- Response2 = class _Response {
29072
- #body;
29073
- #init;
29074
- [getResponseCache]() {
29075
- delete this[cacheKey];
29076
- return this[responseCache] ||= new GlobalResponse(this.#body, this.#init);
29077
- }
29078
- constructor(body, init) {
29079
- let headers;
29080
- this.#body = body;
29081
- if (init instanceof _Response) {
29082
- const cachedGlobalResponse = init[responseCache];
29083
- if (cachedGlobalResponse) {
29084
- this.#init = cachedGlobalResponse;
29085
- this[getResponseCache]();
29086
- return;
29087
- } else {
29088
- this.#init = init.#init;
29089
- headers = new Headers(init.#init.headers);
29090
- }
29091
- } else {
29092
- this.#init = init;
29093
- }
29094
- if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
29095
- headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" };
29096
- this[cacheKey] = [init?.status || 200, body, headers];
29097
- }
29098
- }
29099
- get headers() {
29100
- const cache = this[cacheKey];
29101
- if (cache) {
29102
- if (!(cache[2] instanceof Headers)) {
29103
- cache[2] = new Headers(cache[2]);
29104
- }
29105
- return cache[2];
29106
- }
29107
- return this[getResponseCache]().headers;
29108
- }
29109
- get status() {
29110
- return this[cacheKey]?.[0] ?? this[getResponseCache]().status;
29111
- }
29112
- get ok() {
29113
- const status = this.status;
29114
- return status >= 200 && status < 300;
29115
- }
29116
- };
29117
- ["body", "bodyUsed", "redirected", "statusText", "trailers", "type", "url"].forEach((k) => {
29118
- Object.defineProperty(Response2.prototype, k, {
29119
- get() {
29120
- return this[getResponseCache]()[k];
29121
- }
29122
- });
29123
- });
29124
- ["arrayBuffer", "blob", "clone", "formData", "json", "text"].forEach((k) => {
29125
- Object.defineProperty(Response2.prototype, k, {
29126
- value: function() {
29127
- return this[getResponseCache]()[k]();
29128
- }
29129
- });
29130
- });
29131
- Object.setPrototypeOf(Response2, GlobalResponse);
29132
- Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
29133
- webFetch = global.fetch;
29134
- if (typeof global.crypto === "undefined") {
29135
- global.crypto = crypto;
29136
- }
29137
- global.fetch = (info, init) => {
29138
- init = {
29139
- compress: false,
29140
- ...init
29141
- };
29142
- return webFetch(info, init);
29143
- };
29144
- outgoingEnded = Symbol("outgoingEnded");
29145
- });
29146
-
29147
28700
  // ../../node_modules/.bun/hono@4.10.6/node_modules/hono/dist/compose.js
29148
28701
  var compose = (middleware, onError, onNotFound) => {
29149
28702
  return (context, next) => {
@@ -29303,15 +28856,15 @@ var splitPath = (path) => {
29303
28856
  }
29304
28857
  const match = label.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
29305
28858
  if (match) {
29306
- const cacheKey2 = `${label}#${next}`;
29307
- if (!patternCache[cacheKey2]) {
28859
+ const cacheKey = `${label}#${next}`;
28860
+ if (!patternCache[cacheKey]) {
29308
28861
  if (match[2]) {
29309
- patternCache[cacheKey2] = next && next[0] !== ":" && next[0] !== "*" ? [cacheKey2, match[1], new RegExp(`^${match[2]}(?=/${next})`)] : [label, match[1], new RegExp(`^${match[2]}$`)];
28862
+ patternCache[cacheKey] = next && next[0] !== ":" && next[0] !== "*" ? [cacheKey, match[1], new RegExp(`^${match[2]}(?=/${next})`)] : [label, match[1], new RegExp(`^${match[2]}$`)];
29310
28863
  } else {
29311
- patternCache[cacheKey2] = [label, match[1], true];
28864
+ patternCache[cacheKey] = [label, match[1], true];
29312
28865
  }
29313
28866
  }
29314
- return patternCache[cacheKey2];
28867
+ return patternCache[cacheKey];
29315
28868
  }
29316
28869
  return null;
29317
28870
  }, tryDecode = (str, decoder) => {
@@ -30726,7 +30279,7 @@ var init_hono = __esm(() => {
30726
30279
  });
30727
30280
 
30728
30281
  // ../../node_modules/.bun/hono@4.10.6/node_modules/hono/dist/index.js
30729
- var init_dist2 = __esm(() => {
30282
+ var init_dist = __esm(() => {
30730
30283
  init_hono();
30731
30284
  });
30732
30285
 
@@ -33899,6 +33452,7 @@ class ApiKeyCredentialProvider {
33899
33452
  staticHeaders;
33900
33453
  publicKeyFallback;
33901
33454
  oauthFallback;
33455
+ declaredKey;
33902
33456
  cachedKey;
33903
33457
  resolving;
33904
33458
  constructor(descriptor) {
@@ -33909,9 +33463,17 @@ class ApiKeyCredentialProvider {
33909
33463
  this.staticHeaders = descriptor.staticHeaders ?? {};
33910
33464
  this.publicKeyFallback = descriptor.publicKeyFallback;
33911
33465
  this.oauthFallback = descriptor.oauthFallback;
33466
+ this.declaredKey = descriptor.declaredKey;
33912
33467
  }
33913
33468
  resolveFromEnvConfig() {
33914
- return process.env[this.envVar] || this.aliases.map((a) => process.env[a]).find((v) => !!v) || getApiKey(this.envVar);
33469
+ return process.env[this.envVar] || this.aliases.map((a) => process.env[a]).find((v) => !!v) || getApiKey(this.envVar) || this.resolveDeclared();
33470
+ }
33471
+ resolveDeclared() {
33472
+ try {
33473
+ return this.declaredKey?.() || undefined;
33474
+ } catch {
33475
+ return;
33476
+ }
33915
33477
  }
33916
33478
  hasOauthFallbackFile() {
33917
33479
  if (!this.oauthFallback)
@@ -35780,7 +35342,8 @@ class CredentialAuthority {
35780
35342
  catalogName: descriptor.name,
35781
35343
  envVar: descriptor.envVar,
35782
35344
  aliases: descriptor.aliases,
35783
- authScheme: descriptor.authScheme === "x-api-key" ? "x-api-key" : "bearer"
35345
+ authScheme: descriptor.authScheme === "x-api-key" ? "x-api-key" : "bearer",
35346
+ declaredKey: descriptor.declaredKey
35784
35347
  }), [descriptor.name]);
35785
35348
  }
35786
35349
  async isAvailable(name, opts) {
@@ -37625,6 +37188,61 @@ function ensureAnthropicErrorFormat(status, body) {
37625
37188
  return wrapAnthropicError(status, String(message), errorType);
37626
37189
  }
37627
37190
 
37191
+ // src/handlers/shared/connection-error.ts
37192
+ function findConnectionCode(error46) {
37193
+ let e = error46;
37194
+ const seen = new Set;
37195
+ for (let depth = 0;e && typeof e === "object" && depth < 8 && !seen.has(e); depth++) {
37196
+ seen.add(e);
37197
+ if (typeof e.code === "string" && e.code in CODE_KIND)
37198
+ return e.code;
37199
+ e = e.cause;
37200
+ }
37201
+ const msg = String(error46?.message ?? error46 ?? "");
37202
+ if (/getaddrinfo|ENOTFOUND|EAI_AGAIN|nodename nor servname/i.test(msg))
37203
+ return "ENOTFOUND";
37204
+ return null;
37205
+ }
37206
+ function classifyConnectionError(error46) {
37207
+ const code = findConnectionCode(error46);
37208
+ if (!code)
37209
+ return null;
37210
+ return { kind: CODE_KIND[code] ?? "unreachable", code };
37211
+ }
37212
+ function hostOf(endpoint) {
37213
+ try {
37214
+ return new URL(endpoint).host || endpoint;
37215
+ } catch {
37216
+ return endpoint;
37217
+ }
37218
+ }
37219
+ function buildConnectionErrorMessage(kind, displayName, endpoint) {
37220
+ const host = hostOf(endpoint);
37221
+ switch (kind) {
37222
+ case "dns":
37223
+ return `Cannot resolve ${host} for ${displayName}. This is a DNS/network problem on your machine \u2014 check your internet connection, VPN, or DNS resolver (e.g. Tailscale MagicDNS) \u2014 not ${displayName}.`;
37224
+ case "refused":
37225
+ return `Cannot connect to ${displayName} at ${endpoint}. Make sure the server is running.`;
37226
+ case "unreachable":
37227
+ return `Cannot reach ${displayName} at ${endpoint}. Check your network connection.`;
37228
+ }
37229
+ }
37230
+ var CODE_KIND;
37231
+ var init_connection_error = __esm(() => {
37232
+ CODE_KIND = {
37233
+ ENOTFOUND: "dns",
37234
+ EAI_AGAIN: "dns",
37235
+ ECONNREFUSED: "refused",
37236
+ ETIMEDOUT: "unreachable",
37237
+ ECONNRESET: "unreachable",
37238
+ ENETUNREACH: "unreachable",
37239
+ EHOSTUNREACH: "unreachable",
37240
+ EPIPE: "unreachable",
37241
+ UND_ERR_CONNECT_TIMEOUT: "unreachable",
37242
+ UND_ERR_SOCKET: "unreachable"
37243
+ };
37244
+ });
37245
+
37628
37246
  // src/handlers/shared/stream-parsers/anthropic-sse.ts
37629
37247
  function createAnthropicPassthroughStream(c, response, opts) {
37630
37248
  const encoder = new TextEncoder;
@@ -38960,10 +38578,11 @@ class ComposedHandler {
38960
38578
  try {
38961
38579
  response = this.provider.enqueueRequest ? await this.provider.enqueueRequest(doFetch) : await doFetch();
38962
38580
  } catch (error46) {
38963
- if (error46.code === "ECONNREFUSED" || error46.cause?.code === "ECONNREFUSED") {
38964
- const msg = `Cannot connect to ${this.provider.displayName} at ${endpoint}. Make sure the server is running.`;
38965
- log(`[${this.provider.displayName}] ${msg}`);
38966
- logStderr(`Error: ${msg} Check the server is running.`);
38581
+ const conn = classifyConnectionError(error46);
38582
+ if (conn) {
38583
+ const msg = buildConnectionErrorMessage(conn.kind, this.provider.displayName, endpoint);
38584
+ log(`[${this.provider.displayName}] ${msg} (code=${conn.code})`);
38585
+ logStderr(`Error: ${msg}`);
38967
38586
  reportError({
38968
38587
  error: error46,
38969
38588
  providerName: this.provider.name,
@@ -39332,6 +38951,7 @@ var init_composed_handler = __esm(() => {
39332
38951
  init_stats();
39333
38952
  init_telemetry();
39334
38953
  init_transform();
38954
+ init_connection_error();
39335
38955
  init_openai_compat();
39336
38956
  init_anthropic_sse();
39337
38957
  init_gemini_sse();
@@ -40680,8 +40300,8 @@ function cacheSetFailure(key, reason) {
40680
40300
  function cacheSetRanked(key, ranked) {
40681
40301
  _cache.set(key, { ranked, expiresAt: Date.now() + CACHE_TTL_MS });
40682
40302
  }
40683
- async function discoverViaOpenAIModels(endpoint, headers, cacheKey2) {
40684
- const cached2 = cacheGet(cacheKey2.key, cacheKey2.exclude);
40303
+ async function discoverViaOpenAIModels(endpoint, headers, cacheKey) {
40304
+ const cached2 = cacheGet(cacheKey.key, cacheKey.exclude);
40685
40305
  if (cached2 !== undefined)
40686
40306
  return cached2;
40687
40307
  let response;
@@ -40693,14 +40313,14 @@ async function discoverViaOpenAIModels(endpoint, headers, cacheKey2) {
40693
40313
  });
40694
40314
  } catch (e) {
40695
40315
  const reason = classifyFetchError(e, endpoint);
40696
- log(`[probe-discovery${cacheKey2.displayName ? `:${cacheKey2.displayName}` : ""}] fetch failed: ${reason}`);
40697
- cacheSetFailure(cacheKey2.key, reason);
40316
+ log(`[probe-discovery${cacheKey.displayName ? `:${cacheKey.displayName}` : ""}] fetch failed: ${reason}`);
40317
+ cacheSetFailure(cacheKey.key, reason);
40698
40318
  return { model: null, reason };
40699
40319
  }
40700
40320
  if (!response.ok) {
40701
40321
  const reason = `HTTP ${response.status} from ${endpoint}`;
40702
- log(`[probe-discovery${cacheKey2.displayName ? `:${cacheKey2.displayName}` : ""}] ${reason}`);
40703
- cacheSetFailure(cacheKey2.key, reason);
40322
+ log(`[probe-discovery${cacheKey.displayName ? `:${cacheKey.displayName}` : ""}] ${reason}`);
40323
+ cacheSetFailure(cacheKey.key, reason);
40704
40324
  return { model: null, reason };
40705
40325
  }
40706
40326
  let body;
@@ -40708,7 +40328,7 @@ async function discoverViaOpenAIModels(endpoint, headers, cacheKey2) {
40708
40328
  body = await response.json();
40709
40329
  } catch {
40710
40330
  const reason = "invalid /v1/models response (not JSON)";
40711
- cacheSetFailure(cacheKey2.key, reason);
40331
+ cacheSetFailure(cacheKey.key, reason);
40712
40332
  return { model: null, reason };
40713
40333
  }
40714
40334
  const ids = extractModelIds(body);
@@ -40716,17 +40336,17 @@ async function discoverViaOpenAIModels(endpoint, headers, cacheKey2) {
40716
40336
  const url2 = tryParseUrl(endpoint);
40717
40337
  const host = url2?.host ?? endpoint;
40718
40338
  const reason = `${host} reachable but no models loaded \u2014 load a model in the server UI`;
40719
- cacheSetFailure(cacheKey2.key, reason);
40339
+ cacheSetFailure(cacheKey.key, reason);
40720
40340
  return { model: null, reason };
40721
40341
  }
40722
40342
  const ranked = rankProbeCandidates(ids);
40723
40343
  if (ranked.length === 0) {
40724
40344
  const reason = `no chat-capable model among ${ids.length} listed`;
40725
- cacheSetFailure(cacheKey2.key, reason);
40345
+ cacheSetFailure(cacheKey.key, reason);
40726
40346
  return { model: null, reason };
40727
40347
  }
40728
- cacheSetRanked(cacheKey2.key, ranked);
40729
- const pick2 = ranked.find((m) => !cacheKey2.exclude?.has(m));
40348
+ cacheSetRanked(cacheKey.key, ranked);
40349
+ const pick2 = ranked.find((m) => !cacheKey.exclude?.has(m));
40730
40350
  if (!pick2) {
40731
40351
  return {
40732
40352
  model: null,
@@ -40776,8 +40396,8 @@ function extractModelIds(body) {
40776
40396
  }
40777
40397
  return [];
40778
40398
  }
40779
- async function discoverViaOllama(baseUrl, cacheKey2) {
40780
- const cached2 = cacheGet(cacheKey2.key, cacheKey2.exclude);
40399
+ async function discoverViaOllama(baseUrl, cacheKey) {
40400
+ const cached2 = cacheGet(cacheKey.key, cacheKey.exclude);
40781
40401
  if (cached2 !== undefined)
40782
40402
  return cached2;
40783
40403
  let connectionError;
@@ -40798,7 +40418,7 @@ async function discoverViaOllama(baseUrl, cacheKey2) {
40798
40418
  const candidates = allRaw.filter((m) => isChatCapable(m.name));
40799
40419
  if (candidates.length === 0) {
40800
40420
  const reason = connectionError ?? (allRaw.length === 0 ? `no models on ${baseUrl} (pull one: ollama pull llama3.2)` : `only embedding/non-chat models on ${baseUrl}`);
40801
- cacheSetFailure(cacheKey2.key, reason);
40421
+ cacheSetFailure(cacheKey.key, reason);
40802
40422
  return { model: null, reason };
40803
40423
  }
40804
40424
  const sized = candidates.filter((m) => typeof m.size === "number");
@@ -40810,11 +40430,11 @@ async function discoverViaOllama(baseUrl, cacheKey2) {
40810
40430
  }
40811
40431
  if (ranked.length === 0) {
40812
40432
  const reason = "no chat-capable model on Ollama endpoint";
40813
- cacheSetFailure(cacheKey2.key, reason);
40433
+ cacheSetFailure(cacheKey.key, reason);
40814
40434
  return { model: null, reason };
40815
40435
  }
40816
- cacheSetRanked(cacheKey2.key, ranked);
40817
- const pick2 = ranked.find((m) => !cacheKey2.exclude?.has(m));
40436
+ cacheSetRanked(cacheKey.key, ranked);
40437
+ const pick2 = ranked.find((m) => !cacheKey.exclude?.has(m));
40818
40438
  if (!pick2) {
40819
40439
  return {
40820
40440
  model: null,
@@ -40823,8 +40443,8 @@ async function discoverViaOllama(baseUrl, cacheKey2) {
40823
40443
  }
40824
40444
  return { model: pick2 };
40825
40445
  }
40826
- async function discoverViaLMStudio(baseUrl, headers, cacheKey2) {
40827
- const cached2 = cacheGet(cacheKey2.key, cacheKey2.exclude);
40446
+ async function discoverViaLMStudio(baseUrl, headers, cacheKey) {
40447
+ const cached2 = cacheGet(cacheKey.key, cacheKey.exclude);
40828
40448
  if (cached2 !== undefined)
40829
40449
  return cached2;
40830
40450
  let response;
@@ -40835,17 +40455,17 @@ async function discoverViaLMStudio(baseUrl, headers, cacheKey2) {
40835
40455
  signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
40836
40456
  });
40837
40457
  } catch (e) {
40838
- return discoverViaOpenAIModels(`${baseUrl}/v1/models`, headers, cacheKey2);
40458
+ return discoverViaOpenAIModels(`${baseUrl}/v1/models`, headers, cacheKey);
40839
40459
  }
40840
40460
  if (!response.ok) {
40841
- return discoverViaOpenAIModels(`${baseUrl}/v1/models`, headers, cacheKey2);
40461
+ return discoverViaOpenAIModels(`${baseUrl}/v1/models`, headers, cacheKey);
40842
40462
  }
40843
40463
  let body;
40844
40464
  try {
40845
40465
  body = await response.json();
40846
40466
  } catch {
40847
40467
  const reason = "invalid /api/v0/models response (not JSON)";
40848
- cacheSetFailure(cacheKey2.key, reason);
40468
+ cacheSetFailure(cacheKey.key, reason);
40849
40469
  return { model: null, reason };
40850
40470
  }
40851
40471
  const models = extractLMStudioModels(body);
@@ -40853,7 +40473,7 @@ async function discoverViaLMStudio(baseUrl, headers, cacheKey2) {
40853
40473
  const url2 = tryParseUrl(baseUrl);
40854
40474
  const host = url2?.host ?? baseUrl;
40855
40475
  const reason = `${host} reachable but no models present \u2014 download one in the LM Studio UI`;
40856
- cacheSetFailure(cacheKey2.key, reason);
40476
+ cacheSetFailure(cacheKey.key, reason);
40857
40477
  return { model: null, reason };
40858
40478
  }
40859
40479
  const chatModels = models.filter((m) => isChatCapable(m.id) && m.type !== "embeddings" && m.type !== "embedding");
@@ -40867,11 +40487,11 @@ async function discoverViaLMStudio(baseUrl, headers, cacheKey2) {
40867
40487
  const url2 = tryParseUrl(baseUrl);
40868
40488
  const host = url2?.host ?? baseUrl;
40869
40489
  const reason = `${host} has ${models.length} model(s) but none are chat-capable`;
40870
- cacheSetFailure(cacheKey2.key, reason);
40490
+ cacheSetFailure(cacheKey.key, reason);
40871
40491
  return { model: null, reason };
40872
40492
  }
40873
- cacheSetRanked(cacheKey2.key, ranked);
40874
- const pick2 = ranked.find((m) => !cacheKey2.exclude?.has(m));
40493
+ cacheSetRanked(cacheKey.key, ranked);
40494
+ const pick2 = ranked.find((m) => !cacheKey.exclude?.has(m));
40875
40495
  if (!pick2) {
40876
40496
  return {
40877
40497
  model: null,
@@ -41052,7 +40672,8 @@ function loadCustomEndpoints(config2) {
41052
40672
  credentials.registerApiKeyProvider({
41053
40673
  name: def.name,
41054
40674
  envVar: def.apiKeyEnvVar,
41055
- authScheme: def.authScheme === "x-api-key" ? "x-api-key" : "bearer"
40675
+ authScheme: def.authScheme === "x-api-key" ? "x-api-key" : "bearer",
40676
+ declaredKey: () => resolveDeclaredEndpointKey(validated)
41056
40677
  });
41057
40678
  result.registered++;
41058
40679
  } catch (err) {
@@ -41210,6 +40831,14 @@ function resolveCustomEndpointApiKey(ep) {
41210
40831
  }
41211
40832
  return literal3;
41212
40833
  }
40834
+ function resolveDeclaredEndpointKey(ep) {
40835
+ const declared = ep.apiKey?.trim();
40836
+ if (!declared)
40837
+ return;
40838
+ if (declared.startsWith("op://"))
40839
+ return;
40840
+ return resolveCustomEndpointApiKey(ep) || undefined;
40841
+ }
41213
40842
  function stripTrailingSlash(url2) {
41214
40843
  return url2.replace(/\/+$/, "");
41215
40844
  }
@@ -41325,6 +40954,12 @@ var init_ollama_api_format = __esm(() => {
41325
40954
  import { existsSync as existsSync15, readFileSync as readFileSync12 } from "fs";
41326
40955
  import { homedir as homedir18 } from "os";
41327
40956
  import { join as join18, resolve } from "path";
40957
+ function activeConfigPath() {
40958
+ return activeGlobalConfigFile(join18(homedir18(), ".claudish", "config.json"));
40959
+ }
40960
+ function configLayerLabel() {
40961
+ return getConfigFileOverride() ? activeConfigPath() : "~/.claudish/config.json";
40962
+ }
41328
40963
  function maskKey(key) {
41329
40964
  if (!key)
41330
40965
  return null;
@@ -41344,7 +40979,7 @@ function resolveApiKeyProvenance(envVar, aliases) {
41344
40979
  });
41345
40980
  const configValue = readConfigKey(envVar);
41346
40981
  layers.push({
41347
- source: "~/.claudish/config.json",
40982
+ source: configLayerLabel(),
41348
40983
  maskedValue: maskKey(configValue),
41349
40984
  isActive: false
41350
40985
  });
@@ -41370,7 +41005,7 @@ function resolveApiKeyProvenance(envVar, aliases) {
41370
41005
  layers[0].isActive = true;
41371
41006
  layers[2].isActive = false;
41372
41007
  } else if (configValue && configValue === runtimeValue) {
41373
- effectiveSource = "~/.claudish/config.json";
41008
+ effectiveSource = configLayerLabel();
41374
41009
  layers[1].isActive = true;
41375
41010
  layers[2].isActive = false;
41376
41011
  } else if (isOpHydratedVar(runtimeVar)) {
@@ -41411,7 +41046,7 @@ function readDotenvKey(envVars) {
41411
41046
  }
41412
41047
  function readConfigKey(envVar) {
41413
41048
  try {
41414
- const configPath = join18(homedir18(), ".claudish", "config.json");
41049
+ const configPath = activeConfigPath();
41415
41050
  if (!existsSync15(configPath))
41416
41051
  return null;
41417
41052
  const cfg = JSON.parse(readFileSync12(configPath, "utf-8"));
@@ -43270,21 +42905,21 @@ class LocalTransport {
43270
42905
  return headers;
43271
42906
  }
43272
42907
  async discoverProbeModel(exclude) {
43273
- const cacheKey2 = {
42908
+ const cacheKey = {
43274
42909
  key: `${this.config.name}:${this.config.baseUrl}`,
43275
42910
  displayName: this.displayName,
43276
42911
  exclude
43277
42912
  };
43278
42913
  if (this.config.name === "ollama") {
43279
42914
  return discoverViaOllama(this.config.baseUrl, {
43280
- ...cacheKey2,
42915
+ ...cacheKey,
43281
42916
  key: `ollama:${this.config.baseUrl}`
43282
42917
  });
43283
42918
  }
43284
42919
  if (this.config.name === "lmstudio") {
43285
- return discoverViaLMStudio(this.config.baseUrl, await this.getHeaders(), cacheKey2);
42920
+ return discoverViaLMStudio(this.config.baseUrl, await this.getHeaders(), cacheKey);
43286
42921
  }
43287
- return discoverViaOpenAIModels(`${this.config.baseUrl}/v1/models`, await this.getHeaders(), cacheKey2);
42922
+ return discoverViaOpenAIModels(`${this.config.baseUrl}/v1/models`, await this.getHeaders(), cacheKey);
43288
42923
  }
43289
42924
  getRequestInit() {
43290
42925
  return {
@@ -44048,9 +43683,9 @@ async function createProxyServer(port, _openrouterApiKey, model, monitorMode = f
44048
43683
  {
44049
43684
  const parsedForFallback = parseModelSpec(target);
44050
43685
  if (!parsedForFallback.isExplicitProvider && parsedForFallback.provider !== "native-anthropic" && !isPoeModel(target)) {
44051
- const cacheKey2 = `fallback:${target}`;
44052
- if (fallbackHandlerCache.has(cacheKey2)) {
44053
- return fallbackHandlerCache.get(cacheKey2);
43686
+ const cacheKey = `fallback:${target}`;
43687
+ if (fallbackHandlerCache.has(cacheKey)) {
43688
+ return fallbackHandlerCache.get(cacheKey);
44054
43689
  }
44055
43690
  await ensureCatalogReady("openrouter", 5000);
44056
43691
  const plan = await route(parsedForFallback.model, effectiveRoutingRules);
@@ -44070,7 +43705,7 @@ async function createProxyServer(port, _openrouterApiKey, model, monitorMode = f
44070
43705
  }
44071
43706
  if (candidates.length > 0) {
44072
43707
  const resultHandler = candidates.length > 1 ? new FallbackHandler(candidates) : candidates[0].handler;
44073
- fallbackHandlerCache.set(cacheKey2, resultHandler);
43708
+ fallbackHandlerCache.set(cacheKey, resultHandler);
44074
43709
  if (!options.quiet && candidates.length > 1) {
44075
43710
  logStderr(`[Route] ${candidates.length} providers for ${parsedForFallback.model}: ${candidates.map((c) => c.name).join(" \u2192 ")}`);
44076
43711
  }
@@ -44202,9 +43837,13 @@ ${plan.hint}` : `[Route] ${plan.reason}`;
44202
43837
  return c.json(wrapAnthropicError(500, String(e)), 500);
44203
43838
  }
44204
43839
  });
44205
- const server = serve({ fetch: app.fetch, port, hostname: "127.0.0.1" });
44206
- const addr = server.address();
44207
- const resolvedPort = typeof addr === "object" && addr?.port ? addr.port : port;
43840
+ const server = Bun.serve({
43841
+ fetch: app.fetch,
43842
+ port,
43843
+ hostname: "127.0.0.1",
43844
+ idleTimeout: 255
43845
+ });
43846
+ const resolvedPort = server.port ?? port;
44208
43847
  log(`[Proxy] Server started on port ${resolvedPort}`);
44209
43848
  warmPricingCache().catch(() => {});
44210
43849
  warmRecommendedModels().catch(() => {});
@@ -44213,7 +43852,7 @@ ${plan.hint}` : `[Route] ${plan.reason}`;
44213
43852
  port: resolvedPort,
44214
43853
  url: `http://127.0.0.1:${resolvedPort}`,
44215
43854
  shutdown: async () => {
44216
- return new Promise((resolve2) => server.close(() => resolve2()));
43855
+ await server.stop(true);
44217
43856
  },
44218
43857
  invalidateHandlerCache: (providerSlug) => {
44219
43858
  if (!providerSlug) {
@@ -44236,7 +43875,6 @@ ${plan.hint}` : `[Route] ${plan.reason}`;
44236
43875
  var RoutingError;
44237
43876
  var init_proxy_server = __esm(() => {
44238
43877
  init_dist();
44239
- init_dist2();
44240
43878
  init_cors();
44241
43879
  init_local_adapter();
44242
43880
  init_openrouter_api_format();
@@ -45673,7 +45311,7 @@ var init_mcp_server = __esm(() => {
45673
45311
  init_proxy_server();
45674
45312
  init_team_orchestrator();
45675
45313
  import_dotenv2 = __toESM(require_main(), 1);
45676
- import_dotenv2.config();
45314
+ import_dotenv2.config({ quiet: true });
45677
45315
  __filename2 = fileURLToPath(import.meta.url);
45678
45316
  __dirname2 = dirname5(__filename2);
45679
45317
  CLAUDISH_CACHE_DIR = join21(homedir20(), ".claudish");
@@ -46085,7 +45723,7 @@ function isUnicodeSupported() {
46085
45723
  return Boolean(process3.env["WT_SESSION"]) || Boolean(process3.env["TERMINUS_SUBLIME"]) || process3.env["ConEmuTask"] === "{cmd::Cmder}" || process3.env["TERM_PROGRAM"] === "Terminus-Sublime" || process3.env["TERM_PROGRAM"] === "vscode" || process3.env["TERM"] === "xterm-256color" || process3.env["TERM"] === "alacritty" || process3.env["TERMINAL_EMULATOR"] === "JetBrains-JediTerm";
46086
45724
  }
46087
45725
  var common, specialMainSymbols, specialFallbackSymbols, mainSymbols, fallbackSymbols, shouldUseMain, figures, dist_default, replacements;
46088
- var init_dist3 = __esm(() => {
45726
+ var init_dist2 = __esm(() => {
46089
45727
  common = {
46090
45728
  circleQuestionMark: "(?)",
46091
45729
  questionMarkPrefix: "(?)",
@@ -46372,7 +46010,7 @@ var init_dist3 = __esm(() => {
46372
46010
  import { styleText } from "util";
46373
46011
  var defaultTheme;
46374
46012
  var init_theme = __esm(() => {
46375
- init_dist3();
46013
+ init_dist2();
46376
46014
  defaultTheme = {
46377
46015
  prefix: {
46378
46016
  idle: styleText("blue", "?"),
@@ -47415,7 +47053,7 @@ var ESC = "\x1B[", cursorLeft, cursorHide, cursorShow, cursorUp = (rows = 1) =>
47415
47053
  }
47416
47054
  return `${ESC}${x + 1}G`;
47417
47055
  }, eraseLine, eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
47418
- var init_dist4 = __esm(() => {
47056
+ var init_dist3 = __esm(() => {
47419
47057
  cursorLeft = ESC + "G";
47420
47058
  cursorHide = ESC + "?25l";
47421
47059
  cursorShow = ESC + "?25h";
@@ -47488,7 +47126,7 @@ var height = (content) => content.split(`
47488
47126
  `).pop() ?? "";
47489
47127
  var init_screen_manager = __esm(() => {
47490
47128
  init_utils();
47491
- init_dist4();
47129
+ init_dist3();
47492
47130
  });
47493
47131
 
47494
47132
  // ../../node_modules/.bun/@inquirer+core@11.0.1+04f2146be16c61ef/node_modules/@inquirer/core/dist/lib/promise-polyfill.js
@@ -47621,11 +47259,11 @@ class Separator {
47621
47259
  }
47622
47260
  }
47623
47261
  var init_Separator = __esm(() => {
47624
- init_dist3();
47262
+ init_dist2();
47625
47263
  });
47626
47264
 
47627
47265
  // ../../node_modules/.bun/@inquirer+core@11.0.1+04f2146be16c61ef/node_modules/@inquirer/core/dist/index.js
47628
- var init_dist5 = __esm(() => {
47266
+ var init_dist4 = __esm(() => {
47629
47267
  init_use_prefix();
47630
47268
  init_use_state();
47631
47269
  init_use_effect();
@@ -47685,11 +47323,11 @@ function normalizeChoices(choices) {
47685
47323
  });
47686
47324
  }
47687
47325
  var checkboxTheme, dist_default2;
47688
- var init_dist6 = __esm(() => {
47689
- init_dist5();
47326
+ var init_dist5 = __esm(() => {
47690
47327
  init_dist4();
47691
47328
  init_dist3();
47692
- init_dist5();
47329
+ init_dist2();
47330
+ init_dist4();
47693
47331
  checkboxTheme = {
47694
47332
  icon: {
47695
47333
  checked: styleText3("green", dist_default.circleFilled),
@@ -57330,7 +56968,7 @@ class ExternalEditor {
57330
56968
  }
57331
56969
  }
57332
56970
  var import_chardet, import_iconv_lite;
57333
- var init_dist7 = __esm(() => {
56971
+ var init_dist6 = __esm(() => {
57334
56972
  init_CreateFileError();
57335
56973
  init_LaunchEditorError();
57336
56974
  init_ReadFileError();
@@ -57341,9 +56979,9 @@ var init_dist7 = __esm(() => {
57341
56979
 
57342
56980
  // ../../node_modules/.bun/@inquirer+editor@5.0.1+04f2146be16c61ef/node_modules/@inquirer/editor/dist/index.js
57343
56981
  var editorTheme, dist_default3;
57344
- var init_dist8 = __esm(() => {
57345
- init_dist7();
57346
- init_dist5();
56982
+ var init_dist7 = __esm(() => {
56983
+ init_dist6();
56984
+ init_dist4();
57347
56985
  editorTheme = {
57348
56986
  validationFailureMode: "keep"
57349
56987
  };
@@ -57426,8 +57064,8 @@ function boolToString(value) {
57426
57064
  return value ? "Yes" : "No";
57427
57065
  }
57428
57066
  var dist_default4;
57429
- var init_dist9 = __esm(() => {
57430
- init_dist5();
57067
+ var init_dist8 = __esm(() => {
57068
+ init_dist4();
57431
57069
  dist_default4 = createPrompt((config3, done) => {
57432
57070
  const { transformer = boolToString } = config3;
57433
57071
  const [status, setStatus] = useState("idle");
@@ -57465,8 +57103,8 @@ var init_dist9 = __esm(() => {
57465
57103
 
57466
57104
  // ../../node_modules/.bun/@inquirer+input@5.0.1+04f2146be16c61ef/node_modules/@inquirer/input/dist/index.js
57467
57105
  var inputTheme, dist_default5;
57468
- var init_dist10 = __esm(() => {
57469
- init_dist5();
57106
+ var init_dist9 = __esm(() => {
57107
+ init_dist4();
57470
57108
  inputTheme = {
57471
57109
  validationFailureMode: "keep"
57472
57110
  };
@@ -57570,8 +57208,8 @@ function validateNumber(value, { min, max, step }) {
57570
57208
  return true;
57571
57209
  }
57572
57210
  var dist_default6;
57573
- var init_dist11 = __esm(() => {
57574
- init_dist5();
57211
+ var init_dist10 = __esm(() => {
57212
+ init_dist4();
57575
57213
  dist_default6 = createPrompt((config3, done) => {
57576
57214
  const { validate: validate2 = () => true, min = -Infinity, max = Infinity, step = 1, required: required2 = false } = config3;
57577
57215
  const theme = makeTheme(config3.theme);
@@ -57654,8 +57292,8 @@ function normalizeChoices2(choices) {
57654
57292
  });
57655
57293
  }
57656
57294
  var helpChoice, dist_default7;
57657
- var init_dist12 = __esm(() => {
57658
- init_dist5();
57295
+ var init_dist11 = __esm(() => {
57296
+ init_dist4();
57659
57297
  helpChoice = {
57660
57298
  key: "h",
57661
57299
  name: "Help, list all options",
@@ -57778,8 +57416,8 @@ function getSelectedChoice(input, choices) {
57778
57416
  return selectedChoice ? [selectedChoice, choices.indexOf(selectedChoice)] : [undefined, undefined];
57779
57417
  }
57780
57418
  var numberRegex, dist_default8;
57781
- var init_dist13 = __esm(() => {
57782
- init_dist5();
57419
+ var init_dist12 = __esm(() => {
57420
+ init_dist4();
57783
57421
  numberRegex = /\d+/;
57784
57422
  dist_default8 = createPrompt((config3, done) => {
57785
57423
  const { loop = true } = config3;
@@ -57857,9 +57495,9 @@ var init_dist13 = __esm(() => {
57857
57495
 
57858
57496
  // ../../node_modules/.bun/@inquirer+password@5.0.1+04f2146be16c61ef/node_modules/@inquirer/password/dist/index.js
57859
57497
  var dist_default9;
57860
- var init_dist14 = __esm(() => {
57861
- init_dist5();
57498
+ var init_dist13 = __esm(() => {
57862
57499
  init_dist4();
57500
+ init_dist3();
57863
57501
  dist_default9 = createPrompt((config3, done) => {
57864
57502
  const { validate: validate2 = () => true } = config3;
57865
57503
  const theme = makeTheme(config3.theme);
@@ -57940,9 +57578,9 @@ function normalizeChoices4(choices) {
57940
57578
  });
57941
57579
  }
57942
57580
  var searchTheme, dist_default10;
57943
- var init_dist15 = __esm(() => {
57944
- init_dist5();
57945
- init_dist3();
57581
+ var init_dist14 = __esm(() => {
57582
+ init_dist4();
57583
+ init_dist2();
57946
57584
  searchTheme = {
57947
57585
  icon: { cursor: dist_default.pointer },
57948
57586
  style: {
@@ -58108,10 +57746,10 @@ function normalizeChoices5(choices) {
58108
57746
  });
58109
57747
  }
58110
57748
  var selectTheme, dist_default11;
58111
- var init_dist16 = __esm(() => {
58112
- init_dist5();
57749
+ var init_dist15 = __esm(() => {
58113
57750
  init_dist4();
58114
57751
  init_dist3();
57752
+ init_dist2();
58115
57753
  selectTheme = {
58116
57754
  icon: { cursor: dist_default.pointer },
58117
57755
  style: {
@@ -58254,8 +57892,9 @@ __export(exports_dist, {
58254
57892
  checkbox: () => dist_default2,
58255
57893
  Separator: () => Separator
58256
57894
  });
58257
- var init_dist17 = __esm(() => {
58258
- init_dist6();
57895
+ var init_dist16 = __esm(() => {
57896
+ init_dist5();
57897
+ init_dist7();
58259
57898
  init_dist8();
58260
57899
  init_dist9();
58261
57900
  init_dist10();
@@ -58264,7 +57903,6 @@ var init_dist17 = __esm(() => {
58264
57903
  init_dist13();
58265
57904
  init_dist14();
58266
57905
  init_dist15();
58267
- init_dist16();
58268
57906
  });
58269
57907
 
58270
57908
  // src/auth/auth-commands.ts
@@ -58330,7 +57968,7 @@ async function logoutCommand(providerArg) {
58330
57968
  }
58331
57969
  var AUTH_PROVIDERS;
58332
57970
  var init_auth_commands = __esm(() => {
58333
- init_dist17();
57971
+ init_dist16();
58334
57972
  init_codex_oauth();
58335
57973
  init_gemini_oauth();
58336
57974
  init_kimi_oauth();
@@ -58367,7 +58005,7 @@ __export(exports_quota_command, {
58367
58005
  });
58368
58006
  async function quotaCommand(provider) {
58369
58007
  if (!provider) {
58370
- const { select } = await Promise.resolve().then(() => (init_dist17(), exports_dist));
58008
+ const { select } = await Promise.resolve().then(() => (init_dist16(), exports_dist));
58371
58009
  const choices = QUOTA_ADAPTERS.map((a) => ({
58372
58010
  name: `${a.name} \u2014 ${a.isAvailable() ? "logged in" : "not logged in"}`,
58373
58011
  value: a
@@ -59255,8 +58893,8 @@ async function selectModel(options = {}) {
59255
58893
  pickerProviders = toPickerProviders(await getInteractiveProviderChoices());
59256
58894
  }
59257
58895
  const loadRemoteModels = async (providerSlug, searchTerm) => {
59258
- const cacheKey2 = `${providerSlug || "__all__"}::${searchTerm}`;
59259
- const cached2 = remoteQueryCache.get(cacheKey2);
58896
+ const cacheKey = `${providerSlug || "__all__"}::${searchTerm}`;
58897
+ const cached2 = remoteQueryCache.get(cacheKey);
59260
58898
  if (cached2) {
59261
58899
  return cached2;
59262
58900
  }
@@ -59269,7 +58907,7 @@ async function selectModel(options = {}) {
59269
58907
  return [];
59270
58908
  }
59271
58909
  })();
59272
- remoteQueryCache.set(cacheKey2, request);
58910
+ remoteQueryCache.set(cacheKey, request);
59273
58911
  return request;
59274
58912
  };
59275
58913
  const ac = new AbortController;
@@ -59608,7 +59246,7 @@ async function confirmAction(message) {
59608
59246
  }
59609
59247
  var pickerProviderToFirebaseSlug, LOCAL_OR_USER_DEPLOYED, PROVIDER_FILTER_ALIASES, ALL_PROVIDER_CHOICES, PROVIDER_MODEL_PREFIX;
59610
59248
  var init_model_selector = __esm(() => {
59611
- init_dist17();
59249
+ init_dist16();
59612
59250
  init_authority();
59613
59251
  init_model_loader();
59614
59252
  init_model_catalog2();
@@ -59875,8 +59513,27 @@ function extractUpstreamStatus(body) {
59875
59513
  return;
59876
59514
  }
59877
59515
  }
59516
+ function extractErrorType(body) {
59517
+ if (!body)
59518
+ return;
59519
+ try {
59520
+ const parsed = JSON.parse(body);
59521
+ const t = parsed?.error?.type;
59522
+ return typeof t === "string" ? t : undefined;
59523
+ } catch {
59524
+ return;
59525
+ }
59526
+ }
59878
59527
  function classifyHttpError(status, body, latencyMs) {
59879
59528
  const lowered = body.toLowerCase();
59529
+ if (extractErrorType(body) === "connection_error") {
59530
+ return {
59531
+ state: "network-error",
59532
+ latencyMs,
59533
+ httpStatus: status,
59534
+ errorMessage: extractErrorMessage(body) || "Cannot reach provider"
59535
+ };
59536
+ }
59880
59537
  const upstream = status === 400 ? extractUpstreamStatus(body) : undefined;
59881
59538
  if (status === 401 || status === 403 || upstream === 401 || upstream === 403) {
59882
59539
  const authStatus = upstream ?? status;
@@ -63693,6 +63350,10 @@ ${h("OPTIONS")}
63693
63350
  ${green("--profile")} ${yellow("<name>")} Use named profile for model mapping (default profile if omitted)
63694
63351
  ${green("--default-provider")} ${yellow("<name>")} Fallback provider for bare model names (builtin or customEndpoints key)
63695
63352
  ${dim("Precedence: this flag > CLAUDISH_DEFAULT_PROVIDER env > config.json")}
63353
+ ${green("--config")} ${yellow("<file>")} Use THIS config file for the run, fully replacing the machine
63354
+ ${dim("global (~/.claudish/config.json) AND project (.claudish.json).")}
63355
+ ${dim("A file naming no op:// source never touches 1Password (no prompt).")}
63356
+ ${dim("Env vars still resolve first. Env: CLAUDISH_CONFIG")}
63696
63357
  ${green("--op")} ${yellow("<op://glob>")} Load API keys from a 1Password item glob (SDK-based, no op CLI)
63697
63358
  ${green("--op")} ${yellow("<glob>")} ${green("--list")} Preview which fields the glob would import (names only, no values)
63698
63359
  ${green("--op-env")} ${yellow("<id>")} Load env vars from a 1Password Environment (highest priority)
@@ -64921,7 +64582,7 @@ ${BOLD3}Examples:${RESET3}
64921
64582
  }
64922
64583
  var RESET3 = "\x1B[0m", BOLD3 = "\x1B[1m", DIM3 = "\x1B[2m", GREEN3 = "\x1B[32m", YELLOW2 = "\x1B[33m", CYAN3 = "\x1B[36m", MAGENTA2 = "\x1B[35m";
64923
64584
  var init_profile_commands = __esm(() => {
64924
- init_dist17();
64585
+ init_dist16();
64925
64586
  init_model_selector();
64926
64587
  init_profile_config();
64927
64588
  });
@@ -70045,8 +69706,8 @@ function App({ requestLogin } = {}) {
70045
69706
  setOpFieldCursor(0);
70046
69707
  setOpFilter("");
70047
69708
  setMode("pick_op_field");
70048
- const cacheKey2 = `${vaultId}:${itemId}`;
70049
- const cached2 = opFieldsCache.current.get(cacheKey2);
69709
+ const cacheKey = `${vaultId}:${itemId}`;
69710
+ const cached2 = opFieldsCache.current.get(cacheKey);
70050
69711
  if (cached2) {
70051
69712
  setOpFields(cached2);
70052
69713
  setStatusMsg(`1Password: ${cached2.length} field${cached2.length === 1 ? "" : "s"} (cached).`);
@@ -70058,7 +69719,7 @@ function App({ requestLogin } = {}) {
70058
69719
  try {
70059
69720
  const auth = await acquireOpAuth();
70060
69721
  const fields = await withSdkRetry(() => discoverItemFieldsById(vaultId, itemId, vaultTitle, itemTitle, { auth }), "tui:load-fields");
70061
- opFieldsCache.current.set(cacheKey2, fields);
69722
+ opFieldsCache.current.set(cacheKey, fields);
70062
69723
  setOpFields(fields);
70063
69724
  setStatusMsg(`1Password: ${fields.length} field${fields.length === 1 ? "" : "s"}.`);
70064
69725
  } catch (err) {
@@ -72375,8 +72036,8 @@ var init_team_grid = __esm(() => {
72375
72036
  init_op_source();
72376
72037
  init_startup_trace();
72377
72038
  var import_dotenv3 = __toESM(require_main(), 1);
72378
- import { readFileSync as readFileSync23 } from "fs";
72379
- import { join as join28 } from "path";
72039
+ import { existsSync as existsSync25, readFileSync as readFileSync23 } from "fs";
72040
+ import { join as join28, resolve as resolve3 } from "path";
72380
72041
  import_dotenv3.config({ quiet: true });
72381
72042
  function classifyStartupKind() {
72382
72043
  const argv = process.argv.slice(2);
@@ -72471,6 +72132,24 @@ async function applyOpImport() {
72471
72132
  }
72472
72133
  process.argv = [...head, ...rebuilt];
72473
72134
  }
72135
+ async function applyConfigOverride() {
72136
+ const { planConfigOverride: planConfigOverride2, setConfigFileOverride: setConfigFileOverride2 } = await Promise.resolve().then(() => exports_config_override);
72137
+ const plan = planConfigOverride2(process.argv.slice(2), process.env, {
72138
+ resolve: resolve3,
72139
+ exists: existsSync25
72140
+ });
72141
+ if (plan.kind === "none")
72142
+ return;
72143
+ if (plan.kind === "error") {
72144
+ console.error(plan.message);
72145
+ process.exit(1);
72146
+ }
72147
+ if (plan.fromFlag)
72148
+ process.argv = [...process.argv.slice(0, 2), ...plan.argv];
72149
+ setConfigFileOverride2(plan.path);
72150
+ process.env.CLAUDISH_CONFIG = plan.path;
72151
+ }
72152
+ await traceSpan("startup:config-override", () => applyConfigOverride());
72474
72153
  await traceSpan("startup:op-env-flags", () => applyOpEnvironment());
72475
72154
  await traceSpan("startup:op-import-flag", () => applyOpImport());
72476
72155
  var isMcpMode = process.argv.includes("--mcp");
@@ -72658,11 +72337,11 @@ Team Status`);
72658
72337
  You can disable it anytime with: --no-auto-approve
72659
72338
 
72660
72339
  `);
72661
- const answer = await new Promise((resolve3) => {
72340
+ const answer = await new Promise((resolve4) => {
72662
72341
  const rl = createInterface2({ input: process.stdin, output: process.stderr });
72663
72342
  rl.question("Enable auto-approve? [Y/n] ", (ans) => {
72664
72343
  rl.close();
72665
- resolve3(ans.trim().toLowerCase());
72344
+ resolve4(ans.trim().toLowerCase());
72666
72345
  });
72667
72346
  });
72668
72347
  const declined = answer === "n" || answer === "no";