srpllm 1.2.6 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import cac from 'cac';
|
|
3
3
|
import ansis from 'ansis';
|
|
4
|
-
import { i as init, u as uninstall, P as version } from './shared/srpllm.
|
|
4
|
+
import { i as init, u as uninstall, P as version } from './shared/srpllm.BvbGqIfZ.mjs';
|
|
5
5
|
import 'node:child_process';
|
|
6
6
|
import 'node:fs';
|
|
7
7
|
import 'node:os';
|
package/dist/index.d.mts
CHANGED
|
@@ -76,6 +76,7 @@ declare function selectInstallMethod(tool: CodeToolType): Promise<InstallMethod>
|
|
|
76
76
|
declare function installTool(tool: CodeToolType, skipMethodSelection?: boolean): Promise<void>;
|
|
77
77
|
declare function uninstallTool(tool: CodeToolType): Promise<boolean>;
|
|
78
78
|
|
|
79
|
+
declare const SRPLLM_DIR: string;
|
|
79
80
|
interface LocalConfig {
|
|
80
81
|
/** 上次选的工具 */
|
|
81
82
|
codeType?: 'claude-code' | 'codex' | 'chatbox';
|
|
@@ -130,5 +131,5 @@ declare function getPlatform(): Platform;
|
|
|
130
131
|
declare function isWindows(): boolean;
|
|
131
132
|
declare function commandExists(command: string): Promise<boolean>;
|
|
132
133
|
|
|
133
|
-
export { CLAUDE_DIR, CLAUDE_SETTINGS_FILE, CODEX_AUTH_FILE, CODEX_CONFIG_FILE, CODEX_DIR, CODE_TOOL_ALIASES, CODE_TOOL_LABELS, CODE_TOOL_TYPES, DEFAULT_CODE_TOOL_TYPE, MODEL_PREFIX, RELAY_PROVIDER_ID, RELAY_TOOL_TYPES, buildModelsChoices, clearClaudeApiConfig, clearCodexApiConfig, commandExists, detectInstalledVersion, displayClaudeConfig, displayCodexConfig, enableCodexFullAccess, ensureClaudeDir, fetchModels, filterByPrefix, getExistingClaudeApiConfig, getExistingCodexConfig, getPlatform, init, installTool, isCliTool, isCodeToolType, isToolInstalled, isWindows, readClaudeSettings, readLocalConfig, resolveCodeToolType, selectInstallMethod, uninstall, uninstallTool, updateLocalConfig, writeClaudeApiConfig, writeCodexApiConfig, writeLocalConfig };
|
|
134
|
+
export { CLAUDE_DIR, CLAUDE_SETTINGS_FILE, CODEX_AUTH_FILE, CODEX_CONFIG_FILE, CODEX_DIR, CODE_TOOL_ALIASES, CODE_TOOL_LABELS, CODE_TOOL_TYPES, DEFAULT_CODE_TOOL_TYPE, MODEL_PREFIX, RELAY_PROVIDER_ID, RELAY_TOOL_TYPES, SRPLLM_DIR, buildModelsChoices, clearClaudeApiConfig, clearCodexApiConfig, commandExists, detectInstalledVersion, displayClaudeConfig, displayCodexConfig, enableCodexFullAccess, ensureClaudeDir, fetchModels, filterByPrefix, getExistingClaudeApiConfig, getExistingCodexConfig, getPlatform, init, installTool, isCliTool, isCodeToolType, isToolInstalled, isWindows, readClaudeSettings, readLocalConfig, resolveCodeToolType, selectInstallMethod, uninstall, uninstallTool, updateLocalConfig, writeClaudeApiConfig, writeCodexApiConfig, writeLocalConfig };
|
|
134
135
|
export type { ClaudeApiConfig, CodeToolType, CodexApiConfig, InstallMethod, LocalConfig, RelayToolType, RemoteModel };
|
package/dist/index.d.ts
CHANGED
|
@@ -76,6 +76,7 @@ declare function selectInstallMethod(tool: CodeToolType): Promise<InstallMethod>
|
|
|
76
76
|
declare function installTool(tool: CodeToolType, skipMethodSelection?: boolean): Promise<void>;
|
|
77
77
|
declare function uninstallTool(tool: CodeToolType): Promise<boolean>;
|
|
78
78
|
|
|
79
|
+
declare const SRPLLM_DIR: string;
|
|
79
80
|
interface LocalConfig {
|
|
80
81
|
/** 上次选的工具 */
|
|
81
82
|
codeType?: 'claude-code' | 'codex' | 'chatbox';
|
|
@@ -130,5 +131,5 @@ declare function getPlatform(): Platform;
|
|
|
130
131
|
declare function isWindows(): boolean;
|
|
131
132
|
declare function commandExists(command: string): Promise<boolean>;
|
|
132
133
|
|
|
133
|
-
export { CLAUDE_DIR, CLAUDE_SETTINGS_FILE, CODEX_AUTH_FILE, CODEX_CONFIG_FILE, CODEX_DIR, CODE_TOOL_ALIASES, CODE_TOOL_LABELS, CODE_TOOL_TYPES, DEFAULT_CODE_TOOL_TYPE, MODEL_PREFIX, RELAY_PROVIDER_ID, RELAY_TOOL_TYPES, buildModelsChoices, clearClaudeApiConfig, clearCodexApiConfig, commandExists, detectInstalledVersion, displayClaudeConfig, displayCodexConfig, enableCodexFullAccess, ensureClaudeDir, fetchModels, filterByPrefix, getExistingClaudeApiConfig, getExistingCodexConfig, getPlatform, init, installTool, isCliTool, isCodeToolType, isToolInstalled, isWindows, readClaudeSettings, readLocalConfig, resolveCodeToolType, selectInstallMethod, uninstall, uninstallTool, updateLocalConfig, writeClaudeApiConfig, writeCodexApiConfig, writeLocalConfig };
|
|
134
|
+
export { CLAUDE_DIR, CLAUDE_SETTINGS_FILE, CODEX_AUTH_FILE, CODEX_CONFIG_FILE, CODEX_DIR, CODE_TOOL_ALIASES, CODE_TOOL_LABELS, CODE_TOOL_TYPES, DEFAULT_CODE_TOOL_TYPE, MODEL_PREFIX, RELAY_PROVIDER_ID, RELAY_TOOL_TYPES, SRPLLM_DIR, buildModelsChoices, clearClaudeApiConfig, clearCodexApiConfig, commandExists, detectInstalledVersion, displayClaudeConfig, displayCodexConfig, enableCodexFullAccess, ensureClaudeDir, fetchModels, filterByPrefix, getExistingClaudeApiConfig, getExistingCodexConfig, getPlatform, init, installTool, isCliTool, isCodeToolType, isToolInstalled, isWindows, readClaudeSettings, readLocalConfig, resolveCodeToolType, selectInstallMethod, uninstall, uninstallTool, updateLocalConfig, writeClaudeApiConfig, writeCodexApiConfig, writeLocalConfig };
|
|
134
135
|
export type { ClaudeApiConfig, CodeToolType, CodexApiConfig, InstallMethod, LocalConfig, RelayToolType, RemoteModel };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as CLAUDE_DIR, b as CLAUDE_SETTINGS_FILE, f as CODEX_AUTH_FILE, e as CODEX_CONFIG_FILE, d as CODEX_DIR, j as CODE_TOOL_ALIASES, k as CODE_TOOL_LABELS, h as CODE_TOOL_TYPES, D as DEFAULT_CODE_TOOL_TYPE, M as MODEL_PREFIX, n as RELAY_PROVIDER_ID, R as RELAY_TOOL_TYPES, N as buildModelsChoices, s as clearClaudeApiConfig, z as clearCodexApiConfig, c as commandExists, E as detectInstalledVersion, t as displayClaudeConfig, A as displayCodexConfig, y as enableCodexFullAccess, o as ensureClaudeDir, L as fetchModels, O as filterByPrefix, q as getExistingClaudeApiConfig, v as getExistingCodexConfig, g as getPlatform, i as init, G as installTool, m as isCliTool, l as isCodeToolType, B as isToolInstalled, a as isWindows, p as readClaudeSettings, I as readLocalConfig, r as resolveCodeToolType, F as selectInstallMethod, u as uninstall, H as uninstallTool, K as updateLocalConfig, w as writeClaudeApiConfig, x as writeCodexApiConfig, J as writeLocalConfig } from './shared/srpllm.
|
|
1
|
+
export { C as CLAUDE_DIR, b as CLAUDE_SETTINGS_FILE, f as CODEX_AUTH_FILE, e as CODEX_CONFIG_FILE, d as CODEX_DIR, j as CODE_TOOL_ALIASES, k as CODE_TOOL_LABELS, h as CODE_TOOL_TYPES, D as DEFAULT_CODE_TOOL_TYPE, M as MODEL_PREFIX, n as RELAY_PROVIDER_ID, R as RELAY_TOOL_TYPES, S as SRPLLM_DIR, N as buildModelsChoices, s as clearClaudeApiConfig, z as clearCodexApiConfig, c as commandExists, E as detectInstalledVersion, t as displayClaudeConfig, A as displayCodexConfig, y as enableCodexFullAccess, o as ensureClaudeDir, L as fetchModels, O as filterByPrefix, q as getExistingClaudeApiConfig, v as getExistingCodexConfig, g as getPlatform, i as init, G as installTool, m as isCliTool, l as isCodeToolType, B as isToolInstalled, a as isWindows, p as readClaudeSettings, I as readLocalConfig, r as resolveCodeToolType, F as selectInstallMethod, u as uninstall, H as uninstallTool, K as updateLocalConfig, w as writeClaudeApiConfig, x as writeCodexApiConfig, J as writeLocalConfig } from './shared/srpllm.BvbGqIfZ.mjs';
|
|
2
2
|
import 'node:child_process';
|
|
3
3
|
import 'node:fs';
|
|
4
4
|
import 'node:os';
|
|
@@ -546,6 +546,26 @@ function updateLocalConfig(patch) {
|
|
|
546
546
|
writeLocalConfig({ ...existing, ...patch });
|
|
547
547
|
}
|
|
548
548
|
|
|
549
|
+
const MODEL_CACHE_FILE = join(SRPLLM_DIR, "models-cache.json");
|
|
550
|
+
function cacheKey(baseUrl) {
|
|
551
|
+
return baseUrl.replace(/\/+$/, "").trim().toLowerCase();
|
|
552
|
+
}
|
|
553
|
+
function readModelCache(baseUrl) {
|
|
554
|
+
const store = readJson(MODEL_CACHE_FILE);
|
|
555
|
+
if (!store)
|
|
556
|
+
return null;
|
|
557
|
+
const entry = store[cacheKey(baseUrl)];
|
|
558
|
+
return entry && Array.isArray(entry.models) ? entry : null;
|
|
559
|
+
}
|
|
560
|
+
function writeModelCache(baseUrl, models) {
|
|
561
|
+
const store = readJson(MODEL_CACHE_FILE) || {};
|
|
562
|
+
store[cacheKey(baseUrl)] = {
|
|
563
|
+
models,
|
|
564
|
+
fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
565
|
+
};
|
|
566
|
+
writeJson(MODEL_CACHE_FILE, store);
|
|
567
|
+
}
|
|
568
|
+
|
|
549
569
|
const LITELLM_WILDCARD_IDS = /* @__PURE__ */ new Set([
|
|
550
570
|
"all-proxy-models",
|
|
551
571
|
"all-team-models",
|
|
@@ -603,7 +623,7 @@ function filterByPrefix(models, prefix) {
|
|
|
603
623
|
return models.filter((m) => m.id.toLowerCase().startsWith(p));
|
|
604
624
|
}
|
|
605
625
|
|
|
606
|
-
const version = "1.2.
|
|
626
|
+
const version = "1.2.7";
|
|
607
627
|
|
|
608
628
|
function displayBanner(codeTool) {
|
|
609
629
|
const tool = codeTool ? ` ${ansis.gray(`\xB7 ${CODE_TOOL_LABELS[codeTool]}`)}` : "";
|
|
@@ -685,10 +705,50 @@ async function fetchModelList(baseUrl, token) {
|
|
|
685
705
|
return null;
|
|
686
706
|
}
|
|
687
707
|
}
|
|
688
|
-
|
|
708
|
+
function formatAge(ms) {
|
|
709
|
+
const sec = Math.floor(ms / 1e3);
|
|
710
|
+
if (sec < 60)
|
|
711
|
+
return `${sec} \u79D2`;
|
|
712
|
+
const min = Math.floor(sec / 60);
|
|
713
|
+
if (min < 60)
|
|
714
|
+
return `${min} \u5206\u949F`;
|
|
715
|
+
const hr = Math.floor(min / 60);
|
|
716
|
+
if (hr < 24)
|
|
717
|
+
return `${hr} \u5C0F\u65F6`;
|
|
718
|
+
const day = Math.floor(hr / 24);
|
|
719
|
+
if (day < 30)
|
|
720
|
+
return `${day} \u5929`;
|
|
721
|
+
const month = Math.floor(day / 30);
|
|
722
|
+
if (month < 12)
|
|
723
|
+
return `${month} \u4E2A\u6708`;
|
|
724
|
+
return `${Math.floor(month / 12)} \u5E74`;
|
|
725
|
+
}
|
|
726
|
+
async function tryCachedModels(baseUrl, prefix, skipPrompt) {
|
|
727
|
+
const cache = readModelCache(baseUrl);
|
|
728
|
+
if (!cache || cache.models.length === 0)
|
|
729
|
+
return null;
|
|
730
|
+
const ageStr = formatAge(Date.now() - new Date(cache.fetchedAt).getTime());
|
|
731
|
+
const filtered = filterByPrefix(cache.models, prefix);
|
|
732
|
+
if (skipPrompt) {
|
|
733
|
+
if (filtered.length > 0) {
|
|
734
|
+
console.log(ansis.gray(`\u2139 \u62C9\u53D6\u5931\u8D25\uFF0C\u5DF2\u56DE\u9000\u5230\u672C\u5730\u7F13\u5B58\u6A21\u578B\u5217\u8868\uFF08${ageStr}\u524D\u62C9\u53D6\uFF0C\u5171 ${cache.models.length} \u4E2A\uFF0C\u8FC7\u6EE4\u540E ${filtered.length} \u4E2A ${prefix}*\uFF09`));
|
|
735
|
+
return filtered;
|
|
736
|
+
}
|
|
737
|
+
return null;
|
|
738
|
+
}
|
|
739
|
+
const hint = filtered.length > 0 ? `\u5171 ${cache.models.length} \u4E2A\u6A21\u578B\uFF0C\u5176\u4E2D ${filtered.length} \u4E2A ${prefix}*` : `\u5171 ${cache.models.length} \u4E2A\u6A21\u578B\uFF0C\u4F46\u65E0 ${prefix}* \u524D\u7F00`;
|
|
740
|
+
console.log(ansis.yellow(`
|
|
741
|
+
\u2139 \u62C9\u53D6\u6A21\u578B\u5217\u8868\u5931\u8D25\uFF0C\u68C0\u6D4B\u5230\u672C\u5730\u7F13\u5B58\uFF08${ageStr}\u524D\uFF0C${hint}\uFF09`));
|
|
742
|
+
const useCache = await confirm("\u662F\u5426\u4F7F\u7528\u672C\u5730\u7F13\u5B58\u7684\u6A21\u578B\u5217\u8868\uFF1F", true);
|
|
743
|
+
if (!useCache)
|
|
744
|
+
return null;
|
|
745
|
+
return filtered.length > 0 ? filtered : null;
|
|
746
|
+
}
|
|
747
|
+
async function fetchFilteredModels(baseUrl, token, prefix, skipPrompt) {
|
|
689
748
|
const allModels = await fetchModelList(baseUrl, token);
|
|
690
749
|
if (!allModels)
|
|
691
|
-
return
|
|
750
|
+
return tryCachedModels(baseUrl, prefix, skipPrompt);
|
|
751
|
+
writeModelCache(baseUrl, allModels);
|
|
692
752
|
const filtered = filterByPrefix(allModels, prefix);
|
|
693
753
|
if (filtered.length === 0) {
|
|
694
754
|
console.log(ansis.yellow(`\u2139 \u5DF2\u83B7\u53D6 ${allModels.length} \u4E2A\u6A21\u578B\uFF0C\u4F46\u65E0 ${prefix}* \u524D\u7F00\u7684\u6A21\u578B\uFF0C\u53EF\u624B\u52A8\u8F93\u5165`));
|
|
@@ -744,7 +804,7 @@ async function configureClaudeCode(options, baseUrl, token, memory) {
|
|
|
744
804
|
return;
|
|
745
805
|
}
|
|
746
806
|
}
|
|
747
|
-
const models = await fetchFilteredModels(baseUrl, token, MODEL_PREFIX["claude-code"]);
|
|
807
|
+
const models = await fetchFilteredModels(baseUrl, token, MODEL_PREFIX["claude-code"], options.skipPrompt);
|
|
748
808
|
const m = memory.claude;
|
|
749
809
|
const model = await promptModelFromList(models, "\u8BF7\u9009\u62E9\u4E3B\u6A21\u578B (ANTHROPIC_MODEL)\uFF1A", options.model, options.skipPrompt, m?.model);
|
|
750
810
|
const opusModel = await promptModelFromList(models, "\u8BF7\u9009\u62E9 Opus \u6863\u6A21\u578B (ANTHROPIC_DEFAULT_OPUS_MODEL)\uFF1A", options.opusModel, options.skipPrompt, m?.opusModel);
|
|
@@ -771,7 +831,7 @@ async function configureCodex(options, baseUrl, token, memory) {
|
|
|
771
831
|
return;
|
|
772
832
|
}
|
|
773
833
|
}
|
|
774
|
-
const models = await fetchFilteredModels(baseUrl, token, MODEL_PREFIX.codex);
|
|
834
|
+
const models = await fetchFilteredModels(baseUrl, token, MODEL_PREFIX.codex, options.skipPrompt);
|
|
775
835
|
const model = await promptModelFromList(models, "\u8BF7\u9009\u62E9\u9ED8\u8BA4\u4F7F\u7528\u7684\u6A21\u578B\uFF1A", options.model, options.skipPrompt, memory.codex?.model);
|
|
776
836
|
const config = { baseUrl, token, model };
|
|
777
837
|
writeCodexApiConfig(config);
|
|
@@ -812,7 +872,7 @@ function getDownloadsDir() {
|
|
|
812
872
|
return fallback;
|
|
813
873
|
}
|
|
814
874
|
async function configureChatbox(options, baseUrl, token, memory) {
|
|
815
|
-
const models = await fetchFilteredModels(baseUrl, token, MODEL_PREFIX.chatbox);
|
|
875
|
+
const models = await fetchFilteredModels(baseUrl, token, MODEL_PREFIX.chatbox, options.skipPrompt);
|
|
816
876
|
const model = await promptModelFromList(models, "\u8BF7\u9009\u62E9\u9ED8\u8BA4\u6A21\u578B\uFF08chat- \u524D\u7F00\uFF09\uFF1A", options.model, options.skipPrompt, memory.chatbox?.model);
|
|
817
877
|
const downloads = getDownloadsDir();
|
|
818
878
|
const filePath = join(downloads, "srpllm-chatbox-config.yaml");
|
|
@@ -959,4 +1019,4 @@ ${ansis.cyan("\u{1F389} \u6E05\u7406\u5B8C\u6210")}`);
|
|
|
959
1019
|
}
|
|
960
1020
|
}
|
|
961
1021
|
|
|
962
|
-
export { displayCodexConfig as A, isToolInstalled as B, CLAUDE_DIR as C, DEFAULT_CODE_TOOL_TYPE as D, detectInstalledVersion as E, selectInstallMethod as F, installTool as G, uninstallTool as H, readLocalConfig as I, writeLocalConfig as J, updateLocalConfig as K, fetchModels as L, MODEL_PREFIX as M, buildModelsChoices as N, filterByPrefix as O, version as P, RELAY_TOOL_TYPES as R, isWindows as a, CLAUDE_SETTINGS_FILE as b, commandExists as c, CODEX_DIR as d, CODEX_CONFIG_FILE as e, CODEX_AUTH_FILE as f, getPlatform as g, CODE_TOOL_TYPES as h, init as i, CODE_TOOL_ALIASES as j, CODE_TOOL_LABELS as k, isCodeToolType as l, isCliTool as m, RELAY_PROVIDER_ID as n, ensureClaudeDir as o, readClaudeSettings as p, getExistingClaudeApiConfig as q, resolveCodeToolType as r, clearClaudeApiConfig as s, displayClaudeConfig as t, uninstall as u, getExistingCodexConfig as v, writeClaudeApiConfig as w, writeCodexApiConfig as x, enableCodexFullAccess as y, clearCodexApiConfig as z };
|
|
1022
|
+
export { displayCodexConfig as A, isToolInstalled as B, CLAUDE_DIR as C, DEFAULT_CODE_TOOL_TYPE as D, detectInstalledVersion as E, selectInstallMethod as F, installTool as G, uninstallTool as H, readLocalConfig as I, writeLocalConfig as J, updateLocalConfig as K, fetchModels as L, MODEL_PREFIX as M, buildModelsChoices as N, filterByPrefix as O, version as P, RELAY_TOOL_TYPES as R, SRPLLM_DIR as S, isWindows as a, CLAUDE_SETTINGS_FILE as b, commandExists as c, CODEX_DIR as d, CODEX_CONFIG_FILE as e, CODEX_AUTH_FILE as f, getPlatform as g, CODE_TOOL_TYPES as h, init as i, CODE_TOOL_ALIASES as j, CODE_TOOL_LABELS as k, isCodeToolType as l, isCliTool as m, RELAY_PROVIDER_ID as n, ensureClaudeDir as o, readClaudeSettings as p, getExistingClaudeApiConfig as q, resolveCodeToolType as r, clearClaudeApiConfig as s, displayClaudeConfig as t, uninstall as u, getExistingCodexConfig as v, writeClaudeApiConfig as w, writeCodexApiConfig as x, enableCodexFullAccess as y, clearCodexApiConfig as z };
|