@router-for-me/pi-cliproxyapi-provider 1.4.21 → 1.4.22

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.
@@ -721,6 +721,7 @@ export function registerRefreshCommand(options: {
721
721
  const refresh = refreshCoordinator?.begin();
722
722
  const { loaded } = await resolveMappedModels(agentDir, connection.baseUrlInput, connection.apiKey, {
723
723
  forceRefresh: true,
724
+ replaceCache: true,
724
725
  fastMode: fastMode.isEnabled(),
725
726
  signal: refresh?.signal,
726
727
  shouldCommit: refresh ? () => refreshCoordinator?.isCurrent(refresh.generation) ?? true : undefined,
@@ -1000,7 +1001,7 @@ export default async function (pi: ExtensionAPI): Promise<void> {
1000
1001
  const connection = resolveConnection(agentDir, identity.providerId);
1001
1002
  const registerConfiguredProvider = async (
1002
1003
  currentConnection: { baseUrlInput: string; apiKey: string },
1003
- options: { forceRefresh?: boolean } = {},
1004
+ options: { forceRefresh?: boolean; replaceCache?: boolean } = {},
1004
1005
  ): Promise<RefreshResult | undefined> => {
1005
1006
  const refresh = modelRefreshCoordinator.begin();
1006
1007
  try {
@@ -1010,6 +1011,7 @@ export default async function (pi: ExtensionAPI): Promise<void> {
1010
1011
  currentConnection.apiKey,
1011
1012
  {
1012
1013
  forceRefresh: options.forceRefresh,
1014
+ replaceCache: options.replaceCache,
1013
1015
  fastMode: fastMode.isEnabled(),
1014
1016
  signal: refresh.signal,
1015
1017
  shouldCommit: () => modelRefreshCoordinator.isCurrent(refresh.generation),
@@ -1101,7 +1103,8 @@ export default async function (pi: ExtensionAPI): Promise<void> {
1101
1103
  streamSimple,
1102
1104
  fastMode,
1103
1105
  refreshCoordinator: modelRefreshCoordinator,
1104
- onRefresh: (currentConnection) => registerConfiguredProvider(currentConnection, { forceRefresh: true }),
1106
+ onRefresh: (currentConnection) =>
1107
+ registerConfiguredProvider(currentConnection, { forceRefresh: true, replaceCache: true }),
1105
1108
  });
1106
1109
 
1107
1110
  if (!connection) {
package/extensions/lib.ts CHANGED
@@ -1043,7 +1043,8 @@ export function mergeModelsWithExistingCache(
1043
1043
 
1044
1044
  /**
1045
1045
  * Load mapped models from the matching cache, or fetch remotely and update the cache.
1046
- * A forced refresh always bypasses the cache.
1046
+ * A forced refresh bypasses the cache read but still retains models missing from the
1047
+ * fresh catalog. replaceCache writes that catalog as-is after a successful fetch.
1047
1048
  */
1048
1049
  export async function resolveMappedModels(
1049
1050
  agentDir: string,
@@ -1051,6 +1052,7 @@ export async function resolveMappedModels(
1051
1052
  apiKey: string,
1052
1053
  options: {
1053
1054
  forceRefresh?: boolean;
1055
+ replaceCache?: boolean;
1054
1056
  fastMode?: boolean;
1055
1057
  signal?: AbortSignal;
1056
1058
  shouldCommit?: () => boolean;
@@ -1061,14 +1063,19 @@ export async function resolveMappedModels(
1061
1063
  options.fastMode === undefined || (cache.fastMode ?? false) === options.fastMode;
1062
1064
 
1063
1065
  const existingCache = loadModelsCache(agentDir, baseUrlInput);
1064
- if (!options.forceRefresh) {
1066
+ if (!options.forceRefresh && !options.replaceCache) {
1065
1067
  if (existingCache && cacheMatchesFastMode(existingCache)) {
1066
1068
  return { loaded: existingCache, fromCache: true };
1067
1069
  }
1068
1070
  }
1069
1071
 
1070
1072
  const fresh = await loadMappedModels(baseUrlInput, apiKey, options.fastMode, agentDir, options.signal);
1071
- const { merged } = mergeModelsWithExistingCache(existingCache, fresh, Date.now(), options.staleTtlMs);
1073
+ const { merged } = mergeModelsWithExistingCache(
1074
+ options.replaceCache ? null : existingCache,
1075
+ fresh,
1076
+ Date.now(),
1077
+ options.staleTtlMs,
1078
+ );
1072
1079
  if (!options.signal?.aborted && (options.shouldCommit?.() ?? true)) {
1073
1080
  saveModelsCache(agentDir, merged);
1074
1081
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@router-for-me/pi-cliproxyapi-provider",
3
- "version": "1.4.21",
3
+ "version": "1.4.22",
4
4
  "description": "Pi provider extension that auto-registers CLIProxyAPI models, plus TUI elapsed/TPS status",
5
5
  "type": "module",
6
6
  "keywords": [