claudish 7.17.1 → 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.
- package/dist/index.js +241 -638
- 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
|
-
|
|
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.
|
|
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
|
-
|
|
27539
|
-
if (!
|
|
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(
|
|
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
|
-
|
|
27597
|
-
|
|
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
|
|
29307
|
-
if (!patternCache[
|
|
28859
|
+
const cacheKey = `${label}#${next}`;
|
|
28860
|
+
if (!patternCache[cacheKey]) {
|
|
29308
28861
|
if (match[2]) {
|
|
29309
|
-
patternCache[
|
|
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[
|
|
28864
|
+
patternCache[cacheKey] = [label, match[1], true];
|
|
29312
28865
|
}
|
|
29313
28866
|
}
|
|
29314
|
-
return patternCache[
|
|
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
|
|
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) {
|
|
@@ -40737,8 +40300,8 @@ function cacheSetFailure(key, reason) {
|
|
|
40737
40300
|
function cacheSetRanked(key, ranked) {
|
|
40738
40301
|
_cache.set(key, { ranked, expiresAt: Date.now() + CACHE_TTL_MS });
|
|
40739
40302
|
}
|
|
40740
|
-
async function discoverViaOpenAIModels(endpoint, headers,
|
|
40741
|
-
const cached2 = cacheGet(
|
|
40303
|
+
async function discoverViaOpenAIModels(endpoint, headers, cacheKey) {
|
|
40304
|
+
const cached2 = cacheGet(cacheKey.key, cacheKey.exclude);
|
|
40742
40305
|
if (cached2 !== undefined)
|
|
40743
40306
|
return cached2;
|
|
40744
40307
|
let response;
|
|
@@ -40750,14 +40313,14 @@ async function discoverViaOpenAIModels(endpoint, headers, cacheKey2) {
|
|
|
40750
40313
|
});
|
|
40751
40314
|
} catch (e) {
|
|
40752
40315
|
const reason = classifyFetchError(e, endpoint);
|
|
40753
|
-
log(`[probe-discovery${
|
|
40754
|
-
cacheSetFailure(
|
|
40316
|
+
log(`[probe-discovery${cacheKey.displayName ? `:${cacheKey.displayName}` : ""}] fetch failed: ${reason}`);
|
|
40317
|
+
cacheSetFailure(cacheKey.key, reason);
|
|
40755
40318
|
return { model: null, reason };
|
|
40756
40319
|
}
|
|
40757
40320
|
if (!response.ok) {
|
|
40758
40321
|
const reason = `HTTP ${response.status} from ${endpoint}`;
|
|
40759
|
-
log(`[probe-discovery${
|
|
40760
|
-
cacheSetFailure(
|
|
40322
|
+
log(`[probe-discovery${cacheKey.displayName ? `:${cacheKey.displayName}` : ""}] ${reason}`);
|
|
40323
|
+
cacheSetFailure(cacheKey.key, reason);
|
|
40761
40324
|
return { model: null, reason };
|
|
40762
40325
|
}
|
|
40763
40326
|
let body;
|
|
@@ -40765,7 +40328,7 @@ async function discoverViaOpenAIModels(endpoint, headers, cacheKey2) {
|
|
|
40765
40328
|
body = await response.json();
|
|
40766
40329
|
} catch {
|
|
40767
40330
|
const reason = "invalid /v1/models response (not JSON)";
|
|
40768
|
-
cacheSetFailure(
|
|
40331
|
+
cacheSetFailure(cacheKey.key, reason);
|
|
40769
40332
|
return { model: null, reason };
|
|
40770
40333
|
}
|
|
40771
40334
|
const ids = extractModelIds(body);
|
|
@@ -40773,17 +40336,17 @@ async function discoverViaOpenAIModels(endpoint, headers, cacheKey2) {
|
|
|
40773
40336
|
const url2 = tryParseUrl(endpoint);
|
|
40774
40337
|
const host = url2?.host ?? endpoint;
|
|
40775
40338
|
const reason = `${host} reachable but no models loaded \u2014 load a model in the server UI`;
|
|
40776
|
-
cacheSetFailure(
|
|
40339
|
+
cacheSetFailure(cacheKey.key, reason);
|
|
40777
40340
|
return { model: null, reason };
|
|
40778
40341
|
}
|
|
40779
40342
|
const ranked = rankProbeCandidates(ids);
|
|
40780
40343
|
if (ranked.length === 0) {
|
|
40781
40344
|
const reason = `no chat-capable model among ${ids.length} listed`;
|
|
40782
|
-
cacheSetFailure(
|
|
40345
|
+
cacheSetFailure(cacheKey.key, reason);
|
|
40783
40346
|
return { model: null, reason };
|
|
40784
40347
|
}
|
|
40785
|
-
cacheSetRanked(
|
|
40786
|
-
const pick2 = ranked.find((m) => !
|
|
40348
|
+
cacheSetRanked(cacheKey.key, ranked);
|
|
40349
|
+
const pick2 = ranked.find((m) => !cacheKey.exclude?.has(m));
|
|
40787
40350
|
if (!pick2) {
|
|
40788
40351
|
return {
|
|
40789
40352
|
model: null,
|
|
@@ -40833,8 +40396,8 @@ function extractModelIds(body) {
|
|
|
40833
40396
|
}
|
|
40834
40397
|
return [];
|
|
40835
40398
|
}
|
|
40836
|
-
async function discoverViaOllama(baseUrl,
|
|
40837
|
-
const cached2 = cacheGet(
|
|
40399
|
+
async function discoverViaOllama(baseUrl, cacheKey) {
|
|
40400
|
+
const cached2 = cacheGet(cacheKey.key, cacheKey.exclude);
|
|
40838
40401
|
if (cached2 !== undefined)
|
|
40839
40402
|
return cached2;
|
|
40840
40403
|
let connectionError;
|
|
@@ -40855,7 +40418,7 @@ async function discoverViaOllama(baseUrl, cacheKey2) {
|
|
|
40855
40418
|
const candidates = allRaw.filter((m) => isChatCapable(m.name));
|
|
40856
40419
|
if (candidates.length === 0) {
|
|
40857
40420
|
const reason = connectionError ?? (allRaw.length === 0 ? `no models on ${baseUrl} (pull one: ollama pull llama3.2)` : `only embedding/non-chat models on ${baseUrl}`);
|
|
40858
|
-
cacheSetFailure(
|
|
40421
|
+
cacheSetFailure(cacheKey.key, reason);
|
|
40859
40422
|
return { model: null, reason };
|
|
40860
40423
|
}
|
|
40861
40424
|
const sized = candidates.filter((m) => typeof m.size === "number");
|
|
@@ -40867,11 +40430,11 @@ async function discoverViaOllama(baseUrl, cacheKey2) {
|
|
|
40867
40430
|
}
|
|
40868
40431
|
if (ranked.length === 0) {
|
|
40869
40432
|
const reason = "no chat-capable model on Ollama endpoint";
|
|
40870
|
-
cacheSetFailure(
|
|
40433
|
+
cacheSetFailure(cacheKey.key, reason);
|
|
40871
40434
|
return { model: null, reason };
|
|
40872
40435
|
}
|
|
40873
|
-
cacheSetRanked(
|
|
40874
|
-
const pick2 = ranked.find((m) => !
|
|
40436
|
+
cacheSetRanked(cacheKey.key, ranked);
|
|
40437
|
+
const pick2 = ranked.find((m) => !cacheKey.exclude?.has(m));
|
|
40875
40438
|
if (!pick2) {
|
|
40876
40439
|
return {
|
|
40877
40440
|
model: null,
|
|
@@ -40880,8 +40443,8 @@ async function discoverViaOllama(baseUrl, cacheKey2) {
|
|
|
40880
40443
|
}
|
|
40881
40444
|
return { model: pick2 };
|
|
40882
40445
|
}
|
|
40883
|
-
async function discoverViaLMStudio(baseUrl, headers,
|
|
40884
|
-
const cached2 = cacheGet(
|
|
40446
|
+
async function discoverViaLMStudio(baseUrl, headers, cacheKey) {
|
|
40447
|
+
const cached2 = cacheGet(cacheKey.key, cacheKey.exclude);
|
|
40885
40448
|
if (cached2 !== undefined)
|
|
40886
40449
|
return cached2;
|
|
40887
40450
|
let response;
|
|
@@ -40892,17 +40455,17 @@ async function discoverViaLMStudio(baseUrl, headers, cacheKey2) {
|
|
|
40892
40455
|
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
|
|
40893
40456
|
});
|
|
40894
40457
|
} catch (e) {
|
|
40895
|
-
return discoverViaOpenAIModels(`${baseUrl}/v1/models`, headers,
|
|
40458
|
+
return discoverViaOpenAIModels(`${baseUrl}/v1/models`, headers, cacheKey);
|
|
40896
40459
|
}
|
|
40897
40460
|
if (!response.ok) {
|
|
40898
|
-
return discoverViaOpenAIModels(`${baseUrl}/v1/models`, headers,
|
|
40461
|
+
return discoverViaOpenAIModels(`${baseUrl}/v1/models`, headers, cacheKey);
|
|
40899
40462
|
}
|
|
40900
40463
|
let body;
|
|
40901
40464
|
try {
|
|
40902
40465
|
body = await response.json();
|
|
40903
40466
|
} catch {
|
|
40904
40467
|
const reason = "invalid /api/v0/models response (not JSON)";
|
|
40905
|
-
cacheSetFailure(
|
|
40468
|
+
cacheSetFailure(cacheKey.key, reason);
|
|
40906
40469
|
return { model: null, reason };
|
|
40907
40470
|
}
|
|
40908
40471
|
const models = extractLMStudioModels(body);
|
|
@@ -40910,7 +40473,7 @@ async function discoverViaLMStudio(baseUrl, headers, cacheKey2) {
|
|
|
40910
40473
|
const url2 = tryParseUrl(baseUrl);
|
|
40911
40474
|
const host = url2?.host ?? baseUrl;
|
|
40912
40475
|
const reason = `${host} reachable but no models present \u2014 download one in the LM Studio UI`;
|
|
40913
|
-
cacheSetFailure(
|
|
40476
|
+
cacheSetFailure(cacheKey.key, reason);
|
|
40914
40477
|
return { model: null, reason };
|
|
40915
40478
|
}
|
|
40916
40479
|
const chatModels = models.filter((m) => isChatCapable(m.id) && m.type !== "embeddings" && m.type !== "embedding");
|
|
@@ -40924,11 +40487,11 @@ async function discoverViaLMStudio(baseUrl, headers, cacheKey2) {
|
|
|
40924
40487
|
const url2 = tryParseUrl(baseUrl);
|
|
40925
40488
|
const host = url2?.host ?? baseUrl;
|
|
40926
40489
|
const reason = `${host} has ${models.length} model(s) but none are chat-capable`;
|
|
40927
|
-
cacheSetFailure(
|
|
40490
|
+
cacheSetFailure(cacheKey.key, reason);
|
|
40928
40491
|
return { model: null, reason };
|
|
40929
40492
|
}
|
|
40930
|
-
cacheSetRanked(
|
|
40931
|
-
const pick2 = ranked.find((m) => !
|
|
40493
|
+
cacheSetRanked(cacheKey.key, ranked);
|
|
40494
|
+
const pick2 = ranked.find((m) => !cacheKey.exclude?.has(m));
|
|
40932
40495
|
if (!pick2) {
|
|
40933
40496
|
return {
|
|
40934
40497
|
model: null,
|
|
@@ -41109,7 +40672,8 @@ function loadCustomEndpoints(config2) {
|
|
|
41109
40672
|
credentials.registerApiKeyProvider({
|
|
41110
40673
|
name: def.name,
|
|
41111
40674
|
envVar: def.apiKeyEnvVar,
|
|
41112
|
-
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)
|
|
41113
40677
|
});
|
|
41114
40678
|
result.registered++;
|
|
41115
40679
|
} catch (err) {
|
|
@@ -41267,6 +40831,14 @@ function resolveCustomEndpointApiKey(ep) {
|
|
|
41267
40831
|
}
|
|
41268
40832
|
return literal3;
|
|
41269
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
|
+
}
|
|
41270
40842
|
function stripTrailingSlash(url2) {
|
|
41271
40843
|
return url2.replace(/\/+$/, "");
|
|
41272
40844
|
}
|
|
@@ -41382,6 +40954,12 @@ var init_ollama_api_format = __esm(() => {
|
|
|
41382
40954
|
import { existsSync as existsSync15, readFileSync as readFileSync12 } from "fs";
|
|
41383
40955
|
import { homedir as homedir18 } from "os";
|
|
41384
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
|
+
}
|
|
41385
40963
|
function maskKey(key) {
|
|
41386
40964
|
if (!key)
|
|
41387
40965
|
return null;
|
|
@@ -41401,7 +40979,7 @@ function resolveApiKeyProvenance(envVar, aliases) {
|
|
|
41401
40979
|
});
|
|
41402
40980
|
const configValue = readConfigKey(envVar);
|
|
41403
40981
|
layers.push({
|
|
41404
|
-
source:
|
|
40982
|
+
source: configLayerLabel(),
|
|
41405
40983
|
maskedValue: maskKey(configValue),
|
|
41406
40984
|
isActive: false
|
|
41407
40985
|
});
|
|
@@ -41427,7 +41005,7 @@ function resolveApiKeyProvenance(envVar, aliases) {
|
|
|
41427
41005
|
layers[0].isActive = true;
|
|
41428
41006
|
layers[2].isActive = false;
|
|
41429
41007
|
} else if (configValue && configValue === runtimeValue) {
|
|
41430
|
-
effectiveSource =
|
|
41008
|
+
effectiveSource = configLayerLabel();
|
|
41431
41009
|
layers[1].isActive = true;
|
|
41432
41010
|
layers[2].isActive = false;
|
|
41433
41011
|
} else if (isOpHydratedVar(runtimeVar)) {
|
|
@@ -41468,7 +41046,7 @@ function readDotenvKey(envVars) {
|
|
|
41468
41046
|
}
|
|
41469
41047
|
function readConfigKey(envVar) {
|
|
41470
41048
|
try {
|
|
41471
|
-
const configPath =
|
|
41049
|
+
const configPath = activeConfigPath();
|
|
41472
41050
|
if (!existsSync15(configPath))
|
|
41473
41051
|
return null;
|
|
41474
41052
|
const cfg = JSON.parse(readFileSync12(configPath, "utf-8"));
|
|
@@ -43327,21 +42905,21 @@ class LocalTransport {
|
|
|
43327
42905
|
return headers;
|
|
43328
42906
|
}
|
|
43329
42907
|
async discoverProbeModel(exclude) {
|
|
43330
|
-
const
|
|
42908
|
+
const cacheKey = {
|
|
43331
42909
|
key: `${this.config.name}:${this.config.baseUrl}`,
|
|
43332
42910
|
displayName: this.displayName,
|
|
43333
42911
|
exclude
|
|
43334
42912
|
};
|
|
43335
42913
|
if (this.config.name === "ollama") {
|
|
43336
42914
|
return discoverViaOllama(this.config.baseUrl, {
|
|
43337
|
-
...
|
|
42915
|
+
...cacheKey,
|
|
43338
42916
|
key: `ollama:${this.config.baseUrl}`
|
|
43339
42917
|
});
|
|
43340
42918
|
}
|
|
43341
42919
|
if (this.config.name === "lmstudio") {
|
|
43342
|
-
return discoverViaLMStudio(this.config.baseUrl, await this.getHeaders(),
|
|
42920
|
+
return discoverViaLMStudio(this.config.baseUrl, await this.getHeaders(), cacheKey);
|
|
43343
42921
|
}
|
|
43344
|
-
return discoverViaOpenAIModels(`${this.config.baseUrl}/v1/models`, await this.getHeaders(),
|
|
42922
|
+
return discoverViaOpenAIModels(`${this.config.baseUrl}/v1/models`, await this.getHeaders(), cacheKey);
|
|
43345
42923
|
}
|
|
43346
42924
|
getRequestInit() {
|
|
43347
42925
|
return {
|
|
@@ -44105,9 +43683,9 @@ async function createProxyServer(port, _openrouterApiKey, model, monitorMode = f
|
|
|
44105
43683
|
{
|
|
44106
43684
|
const parsedForFallback = parseModelSpec(target);
|
|
44107
43685
|
if (!parsedForFallback.isExplicitProvider && parsedForFallback.provider !== "native-anthropic" && !isPoeModel(target)) {
|
|
44108
|
-
const
|
|
44109
|
-
if (fallbackHandlerCache.has(
|
|
44110
|
-
return fallbackHandlerCache.get(
|
|
43686
|
+
const cacheKey = `fallback:${target}`;
|
|
43687
|
+
if (fallbackHandlerCache.has(cacheKey)) {
|
|
43688
|
+
return fallbackHandlerCache.get(cacheKey);
|
|
44111
43689
|
}
|
|
44112
43690
|
await ensureCatalogReady("openrouter", 5000);
|
|
44113
43691
|
const plan = await route(parsedForFallback.model, effectiveRoutingRules);
|
|
@@ -44127,7 +43705,7 @@ async function createProxyServer(port, _openrouterApiKey, model, monitorMode = f
|
|
|
44127
43705
|
}
|
|
44128
43706
|
if (candidates.length > 0) {
|
|
44129
43707
|
const resultHandler = candidates.length > 1 ? new FallbackHandler(candidates) : candidates[0].handler;
|
|
44130
|
-
fallbackHandlerCache.set(
|
|
43708
|
+
fallbackHandlerCache.set(cacheKey, resultHandler);
|
|
44131
43709
|
if (!options.quiet && candidates.length > 1) {
|
|
44132
43710
|
logStderr(`[Route] ${candidates.length} providers for ${parsedForFallback.model}: ${candidates.map((c) => c.name).join(" \u2192 ")}`);
|
|
44133
43711
|
}
|
|
@@ -44259,9 +43837,13 @@ ${plan.hint}` : `[Route] ${plan.reason}`;
|
|
|
44259
43837
|
return c.json(wrapAnthropicError(500, String(e)), 500);
|
|
44260
43838
|
}
|
|
44261
43839
|
});
|
|
44262
|
-
const server = serve({
|
|
44263
|
-
|
|
44264
|
-
|
|
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;
|
|
44265
43847
|
log(`[Proxy] Server started on port ${resolvedPort}`);
|
|
44266
43848
|
warmPricingCache().catch(() => {});
|
|
44267
43849
|
warmRecommendedModels().catch(() => {});
|
|
@@ -44270,7 +43852,7 @@ ${plan.hint}` : `[Route] ${plan.reason}`;
|
|
|
44270
43852
|
port: resolvedPort,
|
|
44271
43853
|
url: `http://127.0.0.1:${resolvedPort}`,
|
|
44272
43854
|
shutdown: async () => {
|
|
44273
|
-
|
|
43855
|
+
await server.stop(true);
|
|
44274
43856
|
},
|
|
44275
43857
|
invalidateHandlerCache: (providerSlug) => {
|
|
44276
43858
|
if (!providerSlug) {
|
|
@@ -44293,7 +43875,6 @@ ${plan.hint}` : `[Route] ${plan.reason}`;
|
|
|
44293
43875
|
var RoutingError;
|
|
44294
43876
|
var init_proxy_server = __esm(() => {
|
|
44295
43877
|
init_dist();
|
|
44296
|
-
init_dist2();
|
|
44297
43878
|
init_cors();
|
|
44298
43879
|
init_local_adapter();
|
|
44299
43880
|
init_openrouter_api_format();
|
|
@@ -45730,7 +45311,7 @@ var init_mcp_server = __esm(() => {
|
|
|
45730
45311
|
init_proxy_server();
|
|
45731
45312
|
init_team_orchestrator();
|
|
45732
45313
|
import_dotenv2 = __toESM(require_main(), 1);
|
|
45733
|
-
import_dotenv2.config();
|
|
45314
|
+
import_dotenv2.config({ quiet: true });
|
|
45734
45315
|
__filename2 = fileURLToPath(import.meta.url);
|
|
45735
45316
|
__dirname2 = dirname5(__filename2);
|
|
45736
45317
|
CLAUDISH_CACHE_DIR = join21(homedir20(), ".claudish");
|
|
@@ -46142,7 +45723,7 @@ function isUnicodeSupported() {
|
|
|
46142
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";
|
|
46143
45724
|
}
|
|
46144
45725
|
var common, specialMainSymbols, specialFallbackSymbols, mainSymbols, fallbackSymbols, shouldUseMain, figures, dist_default, replacements;
|
|
46145
|
-
var
|
|
45726
|
+
var init_dist2 = __esm(() => {
|
|
46146
45727
|
common = {
|
|
46147
45728
|
circleQuestionMark: "(?)",
|
|
46148
45729
|
questionMarkPrefix: "(?)",
|
|
@@ -46429,7 +46010,7 @@ var init_dist3 = __esm(() => {
|
|
|
46429
46010
|
import { styleText } from "util";
|
|
46430
46011
|
var defaultTheme;
|
|
46431
46012
|
var init_theme = __esm(() => {
|
|
46432
|
-
|
|
46013
|
+
init_dist2();
|
|
46433
46014
|
defaultTheme = {
|
|
46434
46015
|
prefix: {
|
|
46435
46016
|
idle: styleText("blue", "?"),
|
|
@@ -47472,7 +47053,7 @@ var ESC = "\x1B[", cursorLeft, cursorHide, cursorShow, cursorUp = (rows = 1) =>
|
|
|
47472
47053
|
}
|
|
47473
47054
|
return `${ESC}${x + 1}G`;
|
|
47474
47055
|
}, eraseLine, eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
|
|
47475
|
-
var
|
|
47056
|
+
var init_dist3 = __esm(() => {
|
|
47476
47057
|
cursorLeft = ESC + "G";
|
|
47477
47058
|
cursorHide = ESC + "?25l";
|
|
47478
47059
|
cursorShow = ESC + "?25h";
|
|
@@ -47545,7 +47126,7 @@ var height = (content) => content.split(`
|
|
|
47545
47126
|
`).pop() ?? "";
|
|
47546
47127
|
var init_screen_manager = __esm(() => {
|
|
47547
47128
|
init_utils();
|
|
47548
|
-
|
|
47129
|
+
init_dist3();
|
|
47549
47130
|
});
|
|
47550
47131
|
|
|
47551
47132
|
// ../../node_modules/.bun/@inquirer+core@11.0.1+04f2146be16c61ef/node_modules/@inquirer/core/dist/lib/promise-polyfill.js
|
|
@@ -47678,11 +47259,11 @@ class Separator {
|
|
|
47678
47259
|
}
|
|
47679
47260
|
}
|
|
47680
47261
|
var init_Separator = __esm(() => {
|
|
47681
|
-
|
|
47262
|
+
init_dist2();
|
|
47682
47263
|
});
|
|
47683
47264
|
|
|
47684
47265
|
// ../../node_modules/.bun/@inquirer+core@11.0.1+04f2146be16c61ef/node_modules/@inquirer/core/dist/index.js
|
|
47685
|
-
var
|
|
47266
|
+
var init_dist4 = __esm(() => {
|
|
47686
47267
|
init_use_prefix();
|
|
47687
47268
|
init_use_state();
|
|
47688
47269
|
init_use_effect();
|
|
@@ -47742,11 +47323,11 @@ function normalizeChoices(choices) {
|
|
|
47742
47323
|
});
|
|
47743
47324
|
}
|
|
47744
47325
|
var checkboxTheme, dist_default2;
|
|
47745
|
-
var
|
|
47746
|
-
init_dist5();
|
|
47326
|
+
var init_dist5 = __esm(() => {
|
|
47747
47327
|
init_dist4();
|
|
47748
47328
|
init_dist3();
|
|
47749
|
-
|
|
47329
|
+
init_dist2();
|
|
47330
|
+
init_dist4();
|
|
47750
47331
|
checkboxTheme = {
|
|
47751
47332
|
icon: {
|
|
47752
47333
|
checked: styleText3("green", dist_default.circleFilled),
|
|
@@ -57387,7 +56968,7 @@ class ExternalEditor {
|
|
|
57387
56968
|
}
|
|
57388
56969
|
}
|
|
57389
56970
|
var import_chardet, import_iconv_lite;
|
|
57390
|
-
var
|
|
56971
|
+
var init_dist6 = __esm(() => {
|
|
57391
56972
|
init_CreateFileError();
|
|
57392
56973
|
init_LaunchEditorError();
|
|
57393
56974
|
init_ReadFileError();
|
|
@@ -57398,9 +56979,9 @@ var init_dist7 = __esm(() => {
|
|
|
57398
56979
|
|
|
57399
56980
|
// ../../node_modules/.bun/@inquirer+editor@5.0.1+04f2146be16c61ef/node_modules/@inquirer/editor/dist/index.js
|
|
57400
56981
|
var editorTheme, dist_default3;
|
|
57401
|
-
var
|
|
57402
|
-
|
|
57403
|
-
|
|
56982
|
+
var init_dist7 = __esm(() => {
|
|
56983
|
+
init_dist6();
|
|
56984
|
+
init_dist4();
|
|
57404
56985
|
editorTheme = {
|
|
57405
56986
|
validationFailureMode: "keep"
|
|
57406
56987
|
};
|
|
@@ -57483,8 +57064,8 @@ function boolToString(value) {
|
|
|
57483
57064
|
return value ? "Yes" : "No";
|
|
57484
57065
|
}
|
|
57485
57066
|
var dist_default4;
|
|
57486
|
-
var
|
|
57487
|
-
|
|
57067
|
+
var init_dist8 = __esm(() => {
|
|
57068
|
+
init_dist4();
|
|
57488
57069
|
dist_default4 = createPrompt((config3, done) => {
|
|
57489
57070
|
const { transformer = boolToString } = config3;
|
|
57490
57071
|
const [status, setStatus] = useState("idle");
|
|
@@ -57522,8 +57103,8 @@ var init_dist9 = __esm(() => {
|
|
|
57522
57103
|
|
|
57523
57104
|
// ../../node_modules/.bun/@inquirer+input@5.0.1+04f2146be16c61ef/node_modules/@inquirer/input/dist/index.js
|
|
57524
57105
|
var inputTheme, dist_default5;
|
|
57525
|
-
var
|
|
57526
|
-
|
|
57106
|
+
var init_dist9 = __esm(() => {
|
|
57107
|
+
init_dist4();
|
|
57527
57108
|
inputTheme = {
|
|
57528
57109
|
validationFailureMode: "keep"
|
|
57529
57110
|
};
|
|
@@ -57627,8 +57208,8 @@ function validateNumber(value, { min, max, step }) {
|
|
|
57627
57208
|
return true;
|
|
57628
57209
|
}
|
|
57629
57210
|
var dist_default6;
|
|
57630
|
-
var
|
|
57631
|
-
|
|
57211
|
+
var init_dist10 = __esm(() => {
|
|
57212
|
+
init_dist4();
|
|
57632
57213
|
dist_default6 = createPrompt((config3, done) => {
|
|
57633
57214
|
const { validate: validate2 = () => true, min = -Infinity, max = Infinity, step = 1, required: required2 = false } = config3;
|
|
57634
57215
|
const theme = makeTheme(config3.theme);
|
|
@@ -57711,8 +57292,8 @@ function normalizeChoices2(choices) {
|
|
|
57711
57292
|
});
|
|
57712
57293
|
}
|
|
57713
57294
|
var helpChoice, dist_default7;
|
|
57714
|
-
var
|
|
57715
|
-
|
|
57295
|
+
var init_dist11 = __esm(() => {
|
|
57296
|
+
init_dist4();
|
|
57716
57297
|
helpChoice = {
|
|
57717
57298
|
key: "h",
|
|
57718
57299
|
name: "Help, list all options",
|
|
@@ -57835,8 +57416,8 @@ function getSelectedChoice(input, choices) {
|
|
|
57835
57416
|
return selectedChoice ? [selectedChoice, choices.indexOf(selectedChoice)] : [undefined, undefined];
|
|
57836
57417
|
}
|
|
57837
57418
|
var numberRegex, dist_default8;
|
|
57838
|
-
var
|
|
57839
|
-
|
|
57419
|
+
var init_dist12 = __esm(() => {
|
|
57420
|
+
init_dist4();
|
|
57840
57421
|
numberRegex = /\d+/;
|
|
57841
57422
|
dist_default8 = createPrompt((config3, done) => {
|
|
57842
57423
|
const { loop = true } = config3;
|
|
@@ -57914,9 +57495,9 @@ var init_dist13 = __esm(() => {
|
|
|
57914
57495
|
|
|
57915
57496
|
// ../../node_modules/.bun/@inquirer+password@5.0.1+04f2146be16c61ef/node_modules/@inquirer/password/dist/index.js
|
|
57916
57497
|
var dist_default9;
|
|
57917
|
-
var
|
|
57918
|
-
init_dist5();
|
|
57498
|
+
var init_dist13 = __esm(() => {
|
|
57919
57499
|
init_dist4();
|
|
57500
|
+
init_dist3();
|
|
57920
57501
|
dist_default9 = createPrompt((config3, done) => {
|
|
57921
57502
|
const { validate: validate2 = () => true } = config3;
|
|
57922
57503
|
const theme = makeTheme(config3.theme);
|
|
@@ -57997,9 +57578,9 @@ function normalizeChoices4(choices) {
|
|
|
57997
57578
|
});
|
|
57998
57579
|
}
|
|
57999
57580
|
var searchTheme, dist_default10;
|
|
58000
|
-
var
|
|
58001
|
-
|
|
58002
|
-
|
|
57581
|
+
var init_dist14 = __esm(() => {
|
|
57582
|
+
init_dist4();
|
|
57583
|
+
init_dist2();
|
|
58003
57584
|
searchTheme = {
|
|
58004
57585
|
icon: { cursor: dist_default.pointer },
|
|
58005
57586
|
style: {
|
|
@@ -58165,10 +57746,10 @@ function normalizeChoices5(choices) {
|
|
|
58165
57746
|
});
|
|
58166
57747
|
}
|
|
58167
57748
|
var selectTheme, dist_default11;
|
|
58168
|
-
var
|
|
58169
|
-
init_dist5();
|
|
57749
|
+
var init_dist15 = __esm(() => {
|
|
58170
57750
|
init_dist4();
|
|
58171
57751
|
init_dist3();
|
|
57752
|
+
init_dist2();
|
|
58172
57753
|
selectTheme = {
|
|
58173
57754
|
icon: { cursor: dist_default.pointer },
|
|
58174
57755
|
style: {
|
|
@@ -58311,8 +57892,9 @@ __export(exports_dist, {
|
|
|
58311
57892
|
checkbox: () => dist_default2,
|
|
58312
57893
|
Separator: () => Separator
|
|
58313
57894
|
});
|
|
58314
|
-
var
|
|
58315
|
-
|
|
57895
|
+
var init_dist16 = __esm(() => {
|
|
57896
|
+
init_dist5();
|
|
57897
|
+
init_dist7();
|
|
58316
57898
|
init_dist8();
|
|
58317
57899
|
init_dist9();
|
|
58318
57900
|
init_dist10();
|
|
@@ -58321,7 +57903,6 @@ var init_dist17 = __esm(() => {
|
|
|
58321
57903
|
init_dist13();
|
|
58322
57904
|
init_dist14();
|
|
58323
57905
|
init_dist15();
|
|
58324
|
-
init_dist16();
|
|
58325
57906
|
});
|
|
58326
57907
|
|
|
58327
57908
|
// src/auth/auth-commands.ts
|
|
@@ -58387,7 +57968,7 @@ async function logoutCommand(providerArg) {
|
|
|
58387
57968
|
}
|
|
58388
57969
|
var AUTH_PROVIDERS;
|
|
58389
57970
|
var init_auth_commands = __esm(() => {
|
|
58390
|
-
|
|
57971
|
+
init_dist16();
|
|
58391
57972
|
init_codex_oauth();
|
|
58392
57973
|
init_gemini_oauth();
|
|
58393
57974
|
init_kimi_oauth();
|
|
@@ -58424,7 +58005,7 @@ __export(exports_quota_command, {
|
|
|
58424
58005
|
});
|
|
58425
58006
|
async function quotaCommand(provider) {
|
|
58426
58007
|
if (!provider) {
|
|
58427
|
-
const { select } = await Promise.resolve().then(() => (
|
|
58008
|
+
const { select } = await Promise.resolve().then(() => (init_dist16(), exports_dist));
|
|
58428
58009
|
const choices = QUOTA_ADAPTERS.map((a) => ({
|
|
58429
58010
|
name: `${a.name} \u2014 ${a.isAvailable() ? "logged in" : "not logged in"}`,
|
|
58430
58011
|
value: a
|
|
@@ -59312,8 +58893,8 @@ async function selectModel(options = {}) {
|
|
|
59312
58893
|
pickerProviders = toPickerProviders(await getInteractiveProviderChoices());
|
|
59313
58894
|
}
|
|
59314
58895
|
const loadRemoteModels = async (providerSlug, searchTerm) => {
|
|
59315
|
-
const
|
|
59316
|
-
const cached2 = remoteQueryCache.get(
|
|
58896
|
+
const cacheKey = `${providerSlug || "__all__"}::${searchTerm}`;
|
|
58897
|
+
const cached2 = remoteQueryCache.get(cacheKey);
|
|
59317
58898
|
if (cached2) {
|
|
59318
58899
|
return cached2;
|
|
59319
58900
|
}
|
|
@@ -59326,7 +58907,7 @@ async function selectModel(options = {}) {
|
|
|
59326
58907
|
return [];
|
|
59327
58908
|
}
|
|
59328
58909
|
})();
|
|
59329
|
-
remoteQueryCache.set(
|
|
58910
|
+
remoteQueryCache.set(cacheKey, request);
|
|
59330
58911
|
return request;
|
|
59331
58912
|
};
|
|
59332
58913
|
const ac = new AbortController;
|
|
@@ -59665,7 +59246,7 @@ async function confirmAction(message) {
|
|
|
59665
59246
|
}
|
|
59666
59247
|
var pickerProviderToFirebaseSlug, LOCAL_OR_USER_DEPLOYED, PROVIDER_FILTER_ALIASES, ALL_PROVIDER_CHOICES, PROVIDER_MODEL_PREFIX;
|
|
59667
59248
|
var init_model_selector = __esm(() => {
|
|
59668
|
-
|
|
59249
|
+
init_dist16();
|
|
59669
59250
|
init_authority();
|
|
59670
59251
|
init_model_loader();
|
|
59671
59252
|
init_model_catalog2();
|
|
@@ -63769,6 +63350,10 @@ ${h("OPTIONS")}
|
|
|
63769
63350
|
${green("--profile")} ${yellow("<name>")} Use named profile for model mapping (default profile if omitted)
|
|
63770
63351
|
${green("--default-provider")} ${yellow("<name>")} Fallback provider for bare model names (builtin or customEndpoints key)
|
|
63771
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")}
|
|
63772
63357
|
${green("--op")} ${yellow("<op://glob>")} Load API keys from a 1Password item glob (SDK-based, no op CLI)
|
|
63773
63358
|
${green("--op")} ${yellow("<glob>")} ${green("--list")} Preview which fields the glob would import (names only, no values)
|
|
63774
63359
|
${green("--op-env")} ${yellow("<id>")} Load env vars from a 1Password Environment (highest priority)
|
|
@@ -64997,7 +64582,7 @@ ${BOLD3}Examples:${RESET3}
|
|
|
64997
64582
|
}
|
|
64998
64583
|
var RESET3 = "\x1B[0m", BOLD3 = "\x1B[1m", DIM3 = "\x1B[2m", GREEN3 = "\x1B[32m", YELLOW2 = "\x1B[33m", CYAN3 = "\x1B[36m", MAGENTA2 = "\x1B[35m";
|
|
64999
64584
|
var init_profile_commands = __esm(() => {
|
|
65000
|
-
|
|
64585
|
+
init_dist16();
|
|
65001
64586
|
init_model_selector();
|
|
65002
64587
|
init_profile_config();
|
|
65003
64588
|
});
|
|
@@ -70121,8 +69706,8 @@ function App({ requestLogin } = {}) {
|
|
|
70121
69706
|
setOpFieldCursor(0);
|
|
70122
69707
|
setOpFilter("");
|
|
70123
69708
|
setMode("pick_op_field");
|
|
70124
|
-
const
|
|
70125
|
-
const cached2 = opFieldsCache.current.get(
|
|
69709
|
+
const cacheKey = `${vaultId}:${itemId}`;
|
|
69710
|
+
const cached2 = opFieldsCache.current.get(cacheKey);
|
|
70126
69711
|
if (cached2) {
|
|
70127
69712
|
setOpFields(cached2);
|
|
70128
69713
|
setStatusMsg(`1Password: ${cached2.length} field${cached2.length === 1 ? "" : "s"} (cached).`);
|
|
@@ -70134,7 +69719,7 @@ function App({ requestLogin } = {}) {
|
|
|
70134
69719
|
try {
|
|
70135
69720
|
const auth = await acquireOpAuth();
|
|
70136
69721
|
const fields = await withSdkRetry(() => discoverItemFieldsById(vaultId, itemId, vaultTitle, itemTitle, { auth }), "tui:load-fields");
|
|
70137
|
-
opFieldsCache.current.set(
|
|
69722
|
+
opFieldsCache.current.set(cacheKey, fields);
|
|
70138
69723
|
setOpFields(fields);
|
|
70139
69724
|
setStatusMsg(`1Password: ${fields.length} field${fields.length === 1 ? "" : "s"}.`);
|
|
70140
69725
|
} catch (err) {
|
|
@@ -72451,8 +72036,8 @@ var init_team_grid = __esm(() => {
|
|
|
72451
72036
|
init_op_source();
|
|
72452
72037
|
init_startup_trace();
|
|
72453
72038
|
var import_dotenv3 = __toESM(require_main(), 1);
|
|
72454
|
-
import { readFileSync as readFileSync23 } from "fs";
|
|
72455
|
-
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";
|
|
72456
72041
|
import_dotenv3.config({ quiet: true });
|
|
72457
72042
|
function classifyStartupKind() {
|
|
72458
72043
|
const argv = process.argv.slice(2);
|
|
@@ -72547,6 +72132,24 @@ async function applyOpImport() {
|
|
|
72547
72132
|
}
|
|
72548
72133
|
process.argv = [...head, ...rebuilt];
|
|
72549
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());
|
|
72550
72153
|
await traceSpan("startup:op-env-flags", () => applyOpEnvironment());
|
|
72551
72154
|
await traceSpan("startup:op-import-flag", () => applyOpImport());
|
|
72552
72155
|
var isMcpMode = process.argv.includes("--mcp");
|
|
@@ -72734,11 +72337,11 @@ Team Status`);
|
|
|
72734
72337
|
You can disable it anytime with: --no-auto-approve
|
|
72735
72338
|
|
|
72736
72339
|
`);
|
|
72737
|
-
const answer = await new Promise((
|
|
72340
|
+
const answer = await new Promise((resolve4) => {
|
|
72738
72341
|
const rl = createInterface2({ input: process.stdin, output: process.stderr });
|
|
72739
72342
|
rl.question("Enable auto-approve? [Y/n] ", (ans) => {
|
|
72740
72343
|
rl.close();
|
|
72741
|
-
|
|
72344
|
+
resolve4(ans.trim().toLowerCase());
|
|
72742
72345
|
});
|
|
72743
72346
|
});
|
|
72744
72347
|
const declined = answer === "n" || answer === "no";
|