@ashx-j/lunr 0.1.4 → 0.1.6
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/builtin-extensions/index.d.ts +13 -4
- package/dist/builtin-extensions/index.d.ts.map +1 -1
- package/dist/builtin-extensions/index.js +30 -21
- package/dist/builtin-extensions/index.js.map +1 -1
- package/dist/builtin-extensions/lunr-local-providers/index.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-local-providers/index.js +25 -3
- package/dist/builtin-extensions/lunr-local-providers/index.js.map +1 -1
- package/dist/builtin-extensions/lunr-local-providers/local-servers.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-local-providers/local-servers.js +4 -2
- package/dist/builtin-extensions/lunr-local-providers/local-servers.js.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/index.d.ts +2 -3
- package/dist/builtin-extensions/pi-ollama-cloud/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/index.js +4 -25
- package/dist/builtin-extensions/pi-ollama-cloud/index.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js +3 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js +4 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +4 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +20 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/dynamic-fanout.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/dynamic-fanout.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/dynamic-fanout.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js.map +1 -1
- package/dist/catalog/models.json +1 -1
- package/dist/catalog/providers/amazon-bedrock.json +1 -1
- package/dist/catalog/providers/cloudflare-workers-ai.json +1 -1
- package/dist/catalog/providers/huggingface.json +1 -1
- package/dist/catalog/providers/opencode-go.json +1 -1
- package/dist/catalog/providers/openrouter.json +1 -1
- package/dist/catalog/providers/together.json +1 -1
- package/dist/catalog/providers/vercel-ai-gateway.json +1 -1
- package/dist/catalog/publication.json +3 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +19 -4
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +7 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +9 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +74 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +39 -7
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/catalog-merge.d.ts.map +1 -1
- package/dist/core/catalog-merge.js +4 -1
- package/dist/core/catalog-merge.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +2 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +12 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +2 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/grok-cli-auth.d.ts +13 -3
- package/dist/core/grok-cli-auth.d.ts.map +1 -1
- package/dist/core/grok-cli-auth.js +130 -21
- package/dist/core/grok-cli-auth.js.map +1 -1
- package/dist/core/model-runtime.d.ts +9 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +40 -12
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/official-catalog.d.ts +8 -1
- package/dist/core/official-catalog.d.ts.map +1 -1
- package/dist/core/official-catalog.js +38 -11
- package/dist/core/official-catalog.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +28 -4
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/plan-mode.d.ts +2 -0
- package/dist/core/plan-mode.d.ts.map +1 -1
- package/dist/core/plan-mode.js +7 -0
- package/dist/core/plan-mode.js.map +1 -1
- package/dist/core/resource-loader.d.ts +2 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +27 -3
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/subagent-permission-inherit.d.ts +38 -0
- package/dist/core/subagent-permission-inherit.d.ts.map +1 -0
- package/dist/core/subagent-permission-inherit.js +110 -0
- package/dist/core/subagent-permission-inherit.js.map +1 -0
- package/dist/core/usage-service.d.ts.map +1 -1
- package/dist/core/usage-service.js +5 -5
- package/dist/core/usage-service.js.map +1 -1
- package/dist/gateway/agent-bridge.d.ts.map +1 -1
- package/dist/gateway/agent-bridge.js +2 -2
- package/dist/gateway/agent-bridge.js.map +1 -1
- package/dist/gateway/command.d.ts.map +1 -1
- package/dist/gateway/command.js +2 -1
- package/dist/gateway/command.js.map +1 -1
- package/dist/gateway/cron.d.ts.map +1 -1
- package/dist/gateway/cron.js +2 -2
- package/dist/gateway/cron.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +25 -4
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +7 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +35 -8
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +4 -4
|
@@ -5,10 +5,10 @@ import { getAgentDir } from "../config.js";
|
|
|
5
5
|
import { AuthStorage as DefaultAuthStorage } from "./auth-storage.js";
|
|
6
6
|
import { CatalogOverlaySource, knownModelKeys, withCatalogOverlay } from "./catalog-merge.js";
|
|
7
7
|
import { readGrokCliXaiOAuth, wrapXaiGrokCliCredentials } from "./grok-cli-auth.js";
|
|
8
|
-
import { buildLiveOverlay, fetchLiveProviderModels,
|
|
8
|
+
import { buildLiveOverlay, fetchLiveProviderModels, LIVE_LIST_PROVIDER_IDS, } from "./live-catalog.js";
|
|
9
9
|
import { ModelConfig } from "./model-config.js";
|
|
10
10
|
import { FileModelsStore, InMemoryCodingAgentModelsStore } from "./models-store.js";
|
|
11
|
-
import { loadOfficialCatalog, officialCatalogCachePath, officialEntryToModel, officialModelKeys, } from "./official-catalog.js";
|
|
11
|
+
import { loadOfficialCatalog, officialCatalogCachePath, officialEntryToModel, officialModelKeys, preferOfficialCatalog, } from "./official-catalog.js";
|
|
12
12
|
import { composeModelProvider, configuredRequestAuthStatus, resolveCompatibilityRequestConfig, resolveConfiguredModelHeaders, validateExtensionProvider, } from "./provider-composer.js";
|
|
13
13
|
import { RuntimeCredentials } from "./runtime-credentials.js";
|
|
14
14
|
import { SubscriptionManager } from "./subscriptions.js";
|
|
@@ -55,6 +55,9 @@ export class ModelRuntime {
|
|
|
55
55
|
userModels;
|
|
56
56
|
officialCachePath;
|
|
57
57
|
lastCatalogRefresh = { aborted: false, errors: new Map(), live: [], incomplete: [] };
|
|
58
|
+
lastOfficial;
|
|
59
|
+
catalogRefresh;
|
|
60
|
+
catalogRefreshAllowsNetwork = false;
|
|
58
61
|
grokHome;
|
|
59
62
|
constructor(credentials, config, modelsPath, modelsStore, providers, allowModelNetwork, subscriptionManager, catalogDir, grokHome) {
|
|
60
63
|
this.credentials = credentials;
|
|
@@ -150,7 +153,7 @@ export class ModelRuntime {
|
|
|
150
153
|
}
|
|
151
154
|
}
|
|
152
155
|
withLocalCatalog(provider) {
|
|
153
|
-
return
|
|
156
|
+
return withCatalogOverlay(provider, this.overlay);
|
|
154
157
|
}
|
|
155
158
|
bakedInModels(providerId) {
|
|
156
159
|
return [...(this.defaultBuiltins.get(providerId)?.getModels() ?? [])];
|
|
@@ -315,7 +318,7 @@ export class ModelRuntime {
|
|
|
315
318
|
hasRuntimeApiKey(providerId) {
|
|
316
319
|
return this.credentials.hasRuntimeApiKey(providerId);
|
|
317
320
|
}
|
|
318
|
-
async setRuntimeApiKey(providerId, apiKey) {
|
|
321
|
+
async setRuntimeApiKey(providerId, apiKey, options) {
|
|
319
322
|
this.credentials.setRuntimeApiKey(providerId, apiKey);
|
|
320
323
|
const auth = new Map(this.snapshot.auth).set(providerId, { type: "api_key", source: "runtime API key" });
|
|
321
324
|
const configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);
|
|
@@ -327,7 +330,7 @@ export class ModelRuntime {
|
|
|
327
330
|
storedProviders,
|
|
328
331
|
available: this.snapshot.all.filter((model) => configuredProviders.has(model.provider)),
|
|
329
332
|
};
|
|
330
|
-
await this.refresh({ allowNetwork: this.allowModelNetwork });
|
|
333
|
+
await this.refresh({ allowNetwork: options?.allowNetwork ?? this.allowModelNetwork });
|
|
331
334
|
}
|
|
332
335
|
async removeRuntimeApiKey(providerId) {
|
|
333
336
|
this.credentials.removeRuntimeApiKey(providerId);
|
|
@@ -427,10 +430,27 @@ export class ModelRuntime {
|
|
|
427
430
|
await this.refresh({ allowNetwork: this.allowModelNetwork });
|
|
428
431
|
}
|
|
429
432
|
async refresh(options = {}) {
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
433
|
+
const allowNetwork = options.allowNetwork ?? this.allowModelNetwork;
|
|
434
|
+
if (this.catalogRefresh) {
|
|
435
|
+
// Join an in-flight refresh that is at least as capable. A cache-only
|
|
436
|
+
// flight must not swallow a later network refresh.
|
|
437
|
+
if (this.catalogRefreshAllowsNetwork || !allowNetwork) {
|
|
438
|
+
return this.catalogRefresh;
|
|
439
|
+
}
|
|
440
|
+
await this.catalogRefresh.catch(() => { });
|
|
441
|
+
return this.refresh({ ...options, allowNetwork });
|
|
442
|
+
}
|
|
443
|
+
const run = this.executeCatalogRefresh({ ...options, allowNetwork }).finally(() => {
|
|
444
|
+
if (this.catalogRefresh === run) {
|
|
445
|
+
this.catalogRefresh = undefined;
|
|
446
|
+
this.catalogRefreshAllowsNetwork = false;
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
this.catalogRefresh = run;
|
|
450
|
+
this.catalogRefreshAllowsNetwork = allowNetwork;
|
|
451
|
+
return run;
|
|
452
|
+
}
|
|
453
|
+
async executeCatalogRefresh(refreshOptions) {
|
|
434
454
|
const official = await this.refreshOfficialCatalog(refreshOptions.allowNetwork, refreshOptions.signal);
|
|
435
455
|
const live = refreshOptions.allowNetwork
|
|
436
456
|
? await this.refreshLiveCatalogs(official ? officialModelKeys(official.catalog) : new Set(), refreshOptions.signal)
|
|
@@ -474,15 +494,18 @@ export class ModelRuntime {
|
|
|
474
494
|
}
|
|
475
495
|
async refreshOfficialCatalog(allowNetwork, signal) {
|
|
476
496
|
const storedProviders = await this.listStoredProviderIds();
|
|
477
|
-
const loaded = await loadOfficialCatalog({
|
|
497
|
+
const loaded = preferOfficialCatalog(this.lastOfficial, await loadOfficialCatalog({
|
|
478
498
|
allowNetwork,
|
|
479
499
|
cachePath: this.officialCachePath,
|
|
480
500
|
signal,
|
|
481
501
|
providerIds: [...storedProviders],
|
|
482
|
-
});
|
|
502
|
+
}));
|
|
503
|
+
this.lastOfficial = loaded;
|
|
483
504
|
const evicted = this.userModels.evictOfficial(officialModelKeys(loaded.catalog));
|
|
484
505
|
const templateByProvider = new Map();
|
|
485
|
-
const officialModels = loaded.catalog.models
|
|
506
|
+
const officialModels = loaded.catalog.models
|
|
507
|
+
.filter((entry) => storedProviders.has(entry.provider))
|
|
508
|
+
.map((entry) => {
|
|
486
509
|
if (!templateByProvider.has(entry.provider)) {
|
|
487
510
|
templateByProvider.set(entry.provider, this.bakedInModels(entry.provider)[0]);
|
|
488
511
|
}
|
|
@@ -656,4 +679,9 @@ export class ModelRuntime {
|
|
|
656
679
|
void this.refresh({ allowNetwork: false });
|
|
657
680
|
}
|
|
658
681
|
}
|
|
682
|
+
/** TUI init / footer / rebind: cache-only. Live refresh is `/refresh` and the model picker. */
|
|
683
|
+
export async function refreshModelCandidatesForInit(runtime) {
|
|
684
|
+
await runtime.refresh({ allowNetwork: false });
|
|
685
|
+
return runtime.getAvailableSnapshot();
|
|
686
|
+
}
|
|
659
687
|
//# sourceMappingURL=model-runtime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,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Content":["import { dirname, join } from \"node:path\";\nimport {\n\ttype Api,\n\ttype ApiStreamOptions,\n\ttype AssistantMessage,\n\ttype AssistantMessageEventStream,\n\ttype AuthCheck,\n\ttype AuthInteraction,\n\ttype AuthResult,\n\ttype AuthType,\n\ttype Context,\n\ttype Credential,\n\ttype CredentialInfo,\n\ttype CredentialStore,\n\tcreateModels,\n\tlazyStream,\n\ttype Model,\n\ttype Models,\n\ttype ModelsApiStreamOptions,\n\tModelsError,\n\ttype ModelsRefreshOptions,\n\ttype ModelsRefreshResult,\n\ttype ModelsSimpleStreamOptions,\n\ttype ModelsStore,\n\ttype ModelsStreamTransforms,\n\ttype MutableModels,\n\ttype Provider,\n\ttype ProviderHeaders,\n\ttype SimpleStreamOptions,\n\ttype StreamOptions,\n} from \"@ashx-j/lunr-ai\";\nimport * as builtinProviderCatalog from \"@ashx-j/lunr-ai/providers/all\";\nimport { getAgentDir } from \"../config.ts\";\nimport { AuthStorage as DefaultAuthStorage } from \"./auth-storage.ts\";\nimport { CatalogOverlaySource, knownModelKeys, withCatalogOverlay } from \"./catalog-merge.ts\";\nimport { readGrokCliXaiOAuth, wrapXaiGrokCliCredentials } from \"./grok-cli-auth.ts\";\nimport {\n\tbuildLiveOverlay,\n\tfetchLiveProviderModels,\n\ttype IncompleteLiveModel,\n\tisLiveListProvider,\n\tLIVE_LIST_PROVIDER_IDS,\n\ttype LiveCatalogResult,\n} from \"./live-catalog.ts\";\nimport { ModelConfig } from \"./model-config.ts\";\nimport { FileModelsStore, InMemoryCodingAgentModelsStore } from \"./models-store.ts\";\nimport {\n\tloadOfficialCatalog,\n\ttype OfficialCatalogLoadResult,\n\tofficialCatalogCachePath,\n\tofficialEntryToModel,\n\tofficialModelKeys,\n} from \"./official-catalog.ts\";\nimport {\n\ttype AuthStatus,\n\ttype CompatibilityRequestConfig,\n\tcomposeModelProvider,\n\tconfiguredRequestAuthStatus,\n\ttype ProviderConfigInput,\n\tresolveCompatibilityRequestConfig,\n\tresolveConfiguredModelHeaders,\n\tvalidateExtensionProvider,\n} from \"./provider-composer.ts\";\nimport { RuntimeCredentials } from \"./runtime-credentials.ts\";\nimport { SubscriptionManager } from \"./subscriptions.ts\";\nimport { clearPlanUsageCache } from \"./usage-service.ts\";\nimport { type UserModelEntry, UserModelsStore, userEntryToModel, userModelsPath } from \"./user-models.ts\";\n\ninterface ModelRuntimeSnapshot {\n\tall: readonly Model<Api>[];\n\tavailable: readonly Model<Api>[];\n\tconfiguredProviders: ReadonlySet<string>;\n\tstoredProviders: ReadonlySet<string>;\n\tauth: ReadonlyMap<string, AuthCheck | undefined>;\n}\n\nexport interface CreateModelRuntimeOptions {\n\t/** Credential storage. Defaults to the file at authPath. */\n\tcredentials?: CredentialStore;\n\tauthPath?: string;\n\tmodelsPath?: string | null;\n\tmodelsStore?: ModelsStore;\n\tmodelsStorePath?: string;\n\tallowModelNetwork?: boolean;\n\t/** Applied by callers of `refresh()`, not by `create()` (startup is cache-only). */\n\tmodelRefreshTimeoutMs?: number;\n\t/** Unused. Kept so older callers compiling against this options bag still typecheck. */\n\tcatalogBaseUrl?: string;\n\t/** lunr: subscription-key pool. Defaults to subscriptions.json next to authPath (in-memory for custom stores). */\n\tsubscriptions?: SubscriptionManager;\n\t/**\n\t * Grok CLI home (`~/.grok`) used as a SuperGrok OAuth fallback.\n\t * `null` disables the fallback. Custom `credentials` default to disabled\n\t * unless this is an explicit path.\n\t */\n\tgrokHome?: string | null;\n}\n\nexport interface CatalogRefreshResult extends ModelsRefreshResult {\n\tofficial?: OfficialCatalogLoadResult & { evictedUserRows: number };\n\tlive: LiveCatalogResult[];\n\tincomplete: IncompleteLiveModel[];\n}\n\nexport interface ModelRuntimeAuthOverrides {\n\tapiKey?: string;\n\tenv?: Record<string, string>;\n}\n\nfunction mergeHeaders(\n\tbase: ProviderHeaders | undefined,\n\toverride: ProviderHeaders | undefined,\n): ProviderHeaders | undefined {\n\tif (!base && !override) return undefined;\n\tconst merged = { ...base };\n\tfor (const [name, value] of Object.entries(override ?? {})) {\n\t\tconst lowerName = name.toLowerCase();\n\t\tfor (const existingName of Object.keys(merged)) {\n\t\t\tif (existingName.toLowerCase() === lowerName) delete merged[existingName];\n\t\t}\n\t\tmerged[name] = value;\n\t}\n\treturn merged;\n}\n\n/** Configured pi-ai Models collection used by coding-agent and SDK consumers. */\nexport class ModelRuntime implements Models {\n\tprivate readonly models: MutableModels;\n\tprivate readonly credentials: RuntimeCredentials;\n\t/** lunr: per-provider subscription-key pools; rotation mirrors the active key into the credential store. */\n\treadonly subscriptionManager: SubscriptionManager;\n\tprivate readonly defaultBuiltins: ReadonlyMap<string, Provider>;\n\tprivate readonly builtins = new Map<string, Provider>();\n\tprivate readonly extensionProviders = new Map<string, ProviderConfigInput>();\n\tprivate readonly compositionErrors = new Map<string, string>();\n\tprivate readonly modelsPath: string | undefined;\n\tprivate readonly allowModelNetwork: boolean;\n\tprivate config: ModelConfig;\n\tprivate snapshot: ModelRuntimeSnapshot = {\n\t\tall: [],\n\t\tavailable: [],\n\t\tconfiguredProviders: new Set(),\n\t\tstoredProviders: new Set(),\n\t\tauth: new Map(),\n\t};\n\tprivate availabilityRefresh: Promise<void> | undefined;\n\tprivate availabilityError: string | undefined;\n\tprivate readonly modelsStore: ModelsStore;\n\tprivate readonly overlay = new CatalogOverlaySource();\n\tprivate readonly userModels: UserModelsStore;\n\tprivate readonly officialCachePath: string | undefined;\n\tprivate lastCatalogRefresh: CatalogRefreshResult = { aborted: false, errors: new Map(), live: [], incomplete: [] };\n\tprivate readonly grokHome: string | undefined;\n\n\tprivate constructor(\n\t\tcredentials: RuntimeCredentials,\n\t\tconfig: ModelConfig,\n\t\tmodelsPath: string | undefined,\n\t\tmodelsStore: ModelsStore,\n\t\tproviders: readonly Provider[],\n\t\tallowModelNetwork: boolean,\n\t\tsubscriptionManager: SubscriptionManager,\n\t\tcatalogDir: string | undefined,\n\t\tgrokHome: string | undefined,\n\t) {\n\t\tthis.credentials = credentials;\n\t\tthis.config = config;\n\t\tthis.modelsPath = modelsPath;\n\t\tthis.modelsStore = modelsStore;\n\t\tthis.allowModelNetwork = allowModelNetwork;\n\t\tthis.subscriptionManager = subscriptionManager;\n\t\tthis.userModels = new UserModelsStore(catalogDir ? userModelsPath(catalogDir) : undefined);\n\t\tthis.officialCachePath = catalogDir ? officialCatalogCachePath(catalogDir) : undefined;\n\t\tthis.grokHome = grokHome;\n\t\tthis.defaultBuiltins = new Map(providers.map((provider) => [provider.id, provider]));\n\t\tfor (const [providerId, provider] of this.defaultBuiltins) this.builtins.set(providerId, provider);\n\t\tthis.models = createModels({ credentials, modelsStore });\n\t\tthis.rebuildProviders();\n\t}\n\n\tstatic async create(options: CreateModelRuntimeOptions = {}): Promise<ModelRuntime> {\n\t\t// lunr: keep the underlying store — the SubscriptionManager mirrors rotated\n\t\t// keys into it directly, NOT through the RuntimeCredentials overlay (a runtime\n\t\t// --api-key override would shadow the mirror there).\n\t\tconst rawStore = options.credentials ?? DefaultAuthStorage.create(options.authPath);\n\t\tconst grokHomeDisabled =\n\t\t\toptions.grokHome === null || (options.grokHome === undefined && options.credentials !== undefined);\n\t\tconst grokHome = grokHomeDisabled ? undefined : (options.grokHome ?? undefined);\n\t\tconst baseStore = grokHomeDisabled ? rawStore : wrapXaiGrokCliCredentials(rawStore, { grokHome });\n\t\tconst credentials = new RuntimeCredentials(baseStore);\n\t\t// Pool persistence: subscriptions.json next to auth.json. A custom credential\n\t\t// store without an authPath (tests, SDK embeddings) gets a process-local pool\n\t\t// so nothing leaks into the real agent dir.\n\t\tconst subscriptionManager =\n\t\t\toptions.subscriptions ??\n\t\t\t(options.credentials && !options.authPath\n\t\t\t\t? SubscriptionManager.inMemory(baseStore)\n\t\t\t\t: SubscriptionManager.create(\n\t\t\t\t\t\tbaseStore,\n\t\t\t\t\t\toptions.authPath ? join(dirname(options.authPath), \"subscriptions.json\") : undefined,\n\t\t\t\t\t));\n\t\tconst modelsPath =\n\t\t\toptions.modelsPath === null ? undefined : (options.modelsPath ?? join(getAgentDir(), \"models.json\"));\n\t\tconst config = await ModelConfig.load(modelsPath);\n\t\tconst modelsStore =\n\t\t\toptions.modelsStore ??\n\t\t\t(modelsPath\n\t\t\t\t? new FileModelsStore(options.modelsStorePath ?? join(dirname(modelsPath), \"models-store.json\"))\n\t\t\t\t: new InMemoryCodingAgentModelsStore());\n\t\tconst providers = builtinProviderCatalog.builtinProviders();\n\t\tconst catalogDir = modelsPath ? dirname(modelsPath) : options.authPath ? dirname(options.authPath) : undefined;\n\t\tconst runtime = new ModelRuntime(\n\t\t\tcredentials,\n\t\t\tconfig,\n\t\t\tmodelsPath,\n\t\t\tmodelsStore,\n\t\t\tproviders,\n\t\t\toptions.allowModelNetwork ?? process.env.PI_OFFLINE === undefined,\n\t\t\tsubscriptionManager,\n\t\t\tcatalogDir,\n\t\t\tgrokHome,\n\t\t);\n\t\truntime.configureRadiusProviders();\n\t\truntime.rebuildProviders();\n\t\t// lunr: create() must not wait on GitHub / provider /v1/models / a dead NIC.\n\t\t// Disk cache + baked-in + bundled official overlay are enough to start;\n\t\t// /refresh and the model picker still do a live refresh.\n\t\tawait runtime.refresh({ allowNetwork: false });\n\t\treturn runtime;\n\t}\n\n\tprivate configureRadiusProviders(): void {\n\t\tthis.builtins.clear();\n\t\tfor (const [providerId, provider] of this.defaultBuiltins) this.builtins.set(providerId, provider);\n\t\tfor (const providerId of this.config.getProviderIds()) {\n\t\t\tconst config = this.config.getProvider(providerId);\n\t\t\tif (config?.oauth !== \"radius\" || !config.baseUrl) continue;\n\t\t\tthis.builtins.set(\n\t\t\t\tproviderId,\n\t\t\t\tbuiltinProviderCatalog.radiusProvider({\n\t\t\t\t\tid: providerId,\n\t\t\t\t\tname: config.name ?? providerId,\n\t\t\t\t\tgateway: config.baseUrl.replace(/\\/v1\\/?$/u, \"\"),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate providerIds(): Set<string> {\n\t\treturn new Set([...this.builtins.keys(), ...this.config.getProviderIds(), ...this.extensionProviders.keys()]);\n\t}\n\n\tprivate recomposeProvider(providerId: string): void {\n\t\tconst base = this.builtins.get(providerId);\n\t\tconst extension = this.extensionProviders.get(providerId);\n\t\tif (!base && !this.config.getProvider(providerId) && !extension) {\n\t\t\tthis.models.deleteProvider(providerId);\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn;\n\t\t}\n\t\tif (base && !this.config.getProvider(providerId) && !extension) {\n\t\t\t// No models.json/extension overlays: keep builtin auth/stream exact, then apply catalog layers.\n\t\t\tthis.models.setProvider(this.withLocalCatalog(base));\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tthis.models.setProvider(this.withLocalCatalog(composeModelProvider(providerId, base, this.config, extension)));\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t} catch (error) {\n\t\t\tthis.compositionErrors.set(providerId, error instanceof Error ? error.message : String(error));\n\t\t\tif (base) this.models.setProvider(this.withLocalCatalog(base));\n\t\t\telse this.models.deleteProvider(providerId);\n\t\t}\n\t}\n\n\tprivate withLocalCatalog(provider: Provider): Provider {\n\t\treturn isLiveListProvider(provider.id) ? withCatalogOverlay(provider, this.overlay) : provider;\n\t}\n\n\tprivate bakedInModels(providerId: string): Model<Api>[] {\n\t\treturn [...(this.defaultBuiltins.get(providerId)?.getModels() ?? [])];\n\t}\n\n\tprivate rebuildProviders(): void {\n\t\tthis.models.clearProviders();\n\t\tthis.compositionErrors.clear();\n\t\tfor (const providerId of this.providerIds()) this.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t}\n\n\tprivate updateModelSnapshot(): void {\n\t\tconst all = [...this.models.getModels()];\n\t\tthis.snapshot = {\n\t\t\t...this.snapshot,\n\t\t\tall,\n\t\t\tavailable: all.filter((model) => this.snapshot.configuredProviders.has(model.provider)),\n\t\t};\n\t}\n\n\tprivate async listStoredProviderIds(): Promise<Set<string>> {\n\t\tconst credentials = await this.credentials.list();\n\t\treturn new Set(credentials.map((entry) => entry.providerId));\n\t}\n\n\t/** `/model` lists stored creds + models.json/extension keys, never ambient envApiKeyAuth. */\n\tprivate configuredProviderIds(storedProviders: ReadonlySet<string>): Set<string> {\n\t\tconst configured = new Set(storedProviders);\n\t\tfor (const provider of this.models.getProviders()) {\n\t\t\tif (\n\t\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(provider.id), this.extensionProviders.get(provider.id))\n\t\t\t\t\t?.configured\n\t\t\t) {\n\t\t\t\tconfigured.add(provider.id);\n\t\t\t}\n\t\t}\n\t\treturn configured;\n\t}\n\n\tprivate userModelsForStoredProviders(storedProviders: ReadonlySet<string>): Model<Api>[] {\n\t\treturn this.userModels\n\t\t\t.list()\n\t\t\t.filter((row) => storedProviders.has(row.provider))\n\t\t\t.map(userEntryToModel);\n\t}\n\n\tprivate async runAvailabilityRefresh(): Promise<void> {\n\t\tconst providers = this.models.getProviders();\n\t\tconst [available, checks, storedProviders] = await Promise.all([\n\t\t\tthis.models.getAvailable(),\n\t\t\tPromise.all(\n\t\t\t\tproviders.map(\n\t\t\t\t\tasync (provider): Promise<[string, AuthCheck | undefined]> => [\n\t\t\t\t\t\tprovider.id,\n\t\t\t\t\t\tawait this.models.checkAuth(provider.id),\n\t\t\t\t\t],\n\t\t\t\t),\n\t\t\t),\n\t\t\tthis.listStoredProviderIds(),\n\t\t]);\n\t\tconst auth = new Map(checks);\n\t\tconst configuredProviders = this.configuredProviderIds(storedProviders);\n\t\tthis.snapshot = {\n\t\t\tall: [...this.models.getModels()],\n\t\t\tavailable: available.filter((model) => configuredProviders.has(model.provider)),\n\t\t\tconfiguredProviders,\n\t\t\tstoredProviders,\n\t\t\tauth,\n\t\t};\n\t\tthis.availabilityError = undefined;\n\t}\n\n\tprivate queueAvailabilityRefresh(after: Promise<void> | undefined): Promise<void> {\n\t\tconst refresh = (after ?? Promise.resolve()).catch(() => {}).then(() => this.runAvailabilityRefresh());\n\t\tconst recorded = refresh.catch((error) => {\n\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\tthrow error;\n\t\t});\n\t\tconst tracked = recorded.finally(() => {\n\t\t\tif (this.availabilityRefresh === tracked) this.availabilityRefresh = undefined;\n\t\t});\n\t\tthis.availabilityRefresh = tracked;\n\t\treturn tracked;\n\t}\n\n\t/** Coalesce concurrent readers onto the pending refresh. */\n\tprivate refreshAvailability(): Promise<void> {\n\t\treturn this.availabilityRefresh ?? this.queueAvailabilityRefresh(undefined);\n\t}\n\n\t/** Mutations must not observe an in-flight refresh started before them. */\n\tprivate forceRefreshAvailability(): Promise<void> {\n\t\treturn this.queueAvailabilityRefresh(this.availabilityRefresh);\n\t}\n\n\tgetProviders(): readonly Provider[] {\n\t\treturn this.models.getProviders();\n\t}\n\n\tgetProvider(providerId: string): Provider | undefined {\n\t\treturn this.models.getProvider(providerId);\n\t}\n\n\tgetModels(providerId?: string): readonly Model<Api>[] {\n\t\treturn this.models.getModels(providerId);\n\t}\n\n\tgetModel(providerId: string, modelId: string): Model<Api> | undefined {\n\t\treturn this.models.getModel(providerId, modelId);\n\t}\n\n\tasync checkAuth(providerId: string): Promise<AuthCheck | undefined> {\n\t\treturn this.models.checkAuth(providerId);\n\t}\n\n\tasync getAvailable(providerId?: string): Promise<readonly Model<Api>[]> {\n\t\tif (providerId) {\n\t\t\tif (this.availabilityRefresh) {\n\t\t\t\tawait this.availabilityRefresh;\n\t\t\t\treturn this.snapshot.available.filter((model) => model.provider === providerId);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\treturn await this.models.getAvailable(providerId);\n\t\t\t} catch (error) {\n\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tawait this.refreshAvailability();\n\t\treturn this.snapshot.available;\n\t}\n\n\tgetAvailableSnapshot(): readonly Model<Api>[] {\n\t\treturn this.snapshot.available;\n\t}\n\n\tgetError(): string | undefined {\n\t\tconst errors: string[] = [];\n\t\tconst configError = this.config.getError();\n\t\tif (configError) errors.push(configError);\n\t\tfor (const [providerId, error] of this.compositionErrors) {\n\t\t\terrors.push(`Provider \"${providerId}\": ${error}`);\n\t\t}\n\t\tif (this.availabilityError) errors.push(`Availability refresh: ${this.availabilityError}`);\n\t\treturn errors.length > 0 ? errors.join(\"\\n\\n\") : undefined;\n\t}\n\n\tgetRegisteredProviderConfig(providerId: string): ProviderConfigInput | undefined {\n\t\treturn this.extensionProviders.get(providerId);\n\t}\n\n\tgetRegisteredProviderIds(): readonly string[] {\n\t\treturn [...this.extensionProviders.keys()];\n\t}\n\n\t/** @internal Compatibility fallback for ModelRegistry when provider auth is unconfigured. */\n\tgetCompatibilityRequestConfig(model: Model<Api>): CompatibilityRequestConfig {\n\t\treturn resolveCompatibilityRequestConfig(\n\t\t\tmodel,\n\t\t\tthis.config.getProvider(model.provider),\n\t\t\tthis.extensionProviders.get(model.provider),\n\t\t);\n\t}\n\n\tisUsingOAuth(providerId: string): boolean {\n\t\treturn this.snapshot.auth.get(providerId)?.type === \"oauth\";\n\t}\n\n\thasConfiguredAuth(providerId: string): boolean {\n\t\treturn this.snapshot.configuredProviders.has(providerId);\n\t}\n\n\tgetAuth(providerId: string, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: Model<Api>, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tasync getAuth(\n\t\tproviderOrModel: string | Model<Api>,\n\t\toverrides: ModelRuntimeAuthOverrides = {},\n\t): Promise<AuthResult | undefined> {\n\t\tif (typeof providerOrModel === \"string\") return this.models.getAuth(providerOrModel, overrides);\n\t\tconst resolution = await this.models.getAuth(providerOrModel, overrides);\n\t\tif (!resolution) return undefined;\n\t\tconst configuredHeaders = resolveConfiguredModelHeaders(\n\t\t\tproviderOrModel,\n\t\t\tthis.config.getProvider(providerOrModel.provider),\n\t\t\tthis.extensionProviders.get(providerOrModel.provider),\n\t\t\t{ ...(resolution.env ?? {}), ...(overrides.env ?? {}) },\n\t\t);\n\t\treturn {\n\t\t\t...resolution,\n\t\t\tauth: {\n\t\t\t\t...resolution.auth,\n\t\t\t\theaders: mergeHeaders(resolution.auth.headers, configuredHeaders),\n\t\t\t},\n\t\t};\n\t}\n\n\t/** lunr: whether a runtime --api-key override is active for the provider (it shadows auth.json). */\n\thasRuntimeApiKey(providerId: string): boolean {\n\t\treturn this.credentials.hasRuntimeApiKey(providerId);\n\t}\n\n\tasync setRuntimeApiKey(providerId: string, apiKey: string): Promise<void> {\n\t\tthis.credentials.setRuntimeApiKey(providerId, apiKey);\n\t\tconst auth = new Map(this.snapshot.auth).set(providerId, { type: \"api_key\", source: \"runtime API key\" });\n\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);\n\t\tconst storedProviders = new Set(this.snapshot.storedProviders).add(providerId);\n\t\tthis.snapshot = {\n\t\t\t...this.snapshot,\n\t\t\tauth,\n\t\t\tconfiguredProviders,\n\t\t\tstoredProviders,\n\t\t\tavailable: this.snapshot.all.filter((model) => configuredProviders.has(model.provider)),\n\t\t};\n\t\tawait this.refresh({ allowNetwork: this.allowModelNetwork });\n\t}\n\n\tasync removeRuntimeApiKey(providerId: string): Promise<void> {\n\t\tthis.credentials.removeRuntimeApiKey(providerId);\n\t\tawait this.refresh({ allowNetwork: this.allowModelNetwork });\n\t}\n\n\t/** lunr: whether network model-catalog fetches are allowed (offline mode disables them). */\n\tisNetworkAllowed(): boolean {\n\t\treturn this.allowModelNetwork;\n\t}\n\n\tlistCredentials(): Promise<readonly CredentialInfo[]> {\n\t\treturn this.credentials.list();\n\t}\n\n\tgetProviderAuthStatus(providerId: string): AuthStatus {\n\t\tif (this.credentials.hasRuntimeApiKey(providerId)) return { configured: true, source: \"runtime\" };\n\t\tif (this.snapshot.storedProviders.has(providerId)) return { configured: true, source: \"stored\" };\n\t\tconst configured = configuredRequestAuthStatus(\n\t\t\tthis.config.getProvider(providerId),\n\t\t\tthis.extensionProviders.get(providerId),\n\t\t);\n\t\tif (configured) return configured;\n\t\tconst check = this.snapshot.auth.get(providerId);\n\t\treturn check ? { configured: true, source: \"environment\", label: check.source } : { configured: false };\n\t}\n\n\tprivate async prepareRequest(\n\t\tmodel: Model<Api>,\n\t\toptions: (StreamOptions & ModelsStreamTransforms) | undefined,\n\t): Promise<{ provider: Provider; model: Model<Api>; options: StreamOptions }> {\n\t\tconst provider = this.models.getProvider(model.provider);\n\t\tif (!provider) throw new ModelsError(\"provider\", `Unknown provider: ${model.provider}`);\n\t\tconst resolution = await this.getAuth(model, { apiKey: options?.apiKey, env: options?.env });\n\t\tif (!resolution) throw new ModelsError(\"auth\", `Provider is not configured: ${model.provider}`);\n\n\t\tconst { transformHeaders, ...providerOptions } = options ?? {};\n\t\tlet headers = mergeHeaders(resolution.auth.headers, providerOptions.headers);\n\t\tif (transformHeaders) headers = await transformHeaders(headers ?? {});\n\t\tconst env =\n\t\t\tresolution.env || providerOptions.env\n\t\t\t\t? { ...(resolution.env ?? {}), ...(providerOptions.env ?? {}) }\n\t\t\t\t: undefined;\n\t\treturn {\n\t\t\tprovider,\n\t\t\tmodel: resolution.auth.baseUrl ? { ...model, baseUrl: resolution.auth.baseUrl } : model,\n\t\t\toptions: {\n\t\t\t\t...providerOptions,\n\t\t\t\tapiKey: providerOptions.apiKey ?? resolution.auth.apiKey,\n\t\t\t\theaders,\n\t\t\t\tenv,\n\t\t\t},\n\t\t};\n\t}\n\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream {\n\t\treturn lazyStream(model, async () => {\n\t\t\tconst prepared = await this.prepareRequest(\n\t\t\t\tmodel,\n\t\t\t\toptions as (StreamOptions & ModelsStreamTransforms) | undefined,\n\t\t\t);\n\t\t\treturn prepared.provider.stream(\n\t\t\t\tprepared.model as Model<TApi>,\n\t\t\t\tcontext,\n\t\t\t\tprepared.options as ApiStreamOptions<TApi>,\n\t\t\t);\n\t\t});\n\t}\n\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.stream(model, context, options).result();\n\t}\n\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream {\n\t\treturn lazyStream(model, async () => {\n\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\treturn prepared.provider.streamSimple(prepared.model, context, prepared.options as SimpleStreamOptions);\n\t\t});\n\t}\n\n\tcompleteSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage> {\n\t\treturn this.streamSimple(model, context, options).result();\n\t}\n\n\tasync login(providerId: string, type: AuthType, interaction: AuthInteraction): Promise<Credential> {\n\t\tconst credential = await this.models.login(providerId, type, interaction);\n\t\tclearPlanUsageCache();\n\t\tawait this.refresh({ allowNetwork: this.allowModelNetwork });\n\t\treturn credential;\n\t}\n\n\tasync logout(providerId: string): Promise<void> {\n\t\tawait this.models.logout(providerId);\n\t\tawait this.modelsStore.delete(providerId);\n\t\tthis.userModels.evictProvider(providerId);\n\t\tthis.overlay.setLive(providerId, []);\n\t\t// Reset credential-dependent compatibility projections before the unconfigured provider is skipped by refresh.\n\t\tthis.recomposeProvider(providerId);\n\t\tclearPlanUsageCache();\n\t\tawait this.refresh({ allowNetwork: this.allowModelNetwork });\n\t}\n\n\t/** Copy a live Grok CLI SuperGrok session into lunR `auth.json`. */\n\tasync importGrokCliXaiAuth(): Promise<Credential | undefined> {\n\t\tconst grok = readGrokCliXaiOAuth({ grokHome: this.grokHome });\n\t\tif (!grok) return undefined;\n\t\tconst stored = await this.credentials.modify(\"xai\", async () => grok);\n\t\tclearPlanUsageCache();\n\t\tawait this.refresh({ allowNetwork: this.allowModelNetwork });\n\t\treturn stored;\n\t}\n\n\tasync reloadConfig(): Promise<void> {\n\t\tthis.config = await ModelConfig.load(this.modelsPath);\n\t\tthis.configureRadiusProviders();\n\t\tthis.rebuildProviders();\n\t\tawait this.refresh({ allowNetwork: this.allowModelNetwork });\n\t}\n\n\tasync refresh(options: ModelsRefreshOptions = {}): Promise<CatalogRefreshResult> {\n\t\tconst refreshOptions = {\n\t\t\t...options,\n\t\t\tallowNetwork: options.allowNetwork ?? this.allowModelNetwork,\n\t\t};\n\t\tconst official = await this.refreshOfficialCatalog(refreshOptions.allowNetwork, refreshOptions.signal);\n\t\tconst live = refreshOptions.allowNetwork\n\t\t\t? await this.refreshLiveCatalogs(\n\t\t\t\t\tofficial ? officialModelKeys(official.catalog) : new Set(),\n\t\t\t\t\trefreshOptions.signal,\n\t\t\t\t)\n\t\t\t: await this.restoreLiveCatalogs();\n\n\t\t// Radius / local-provider / extension refreshModels hooks. Live-list\n\t\t// providers have no refreshModels, so this does not hit pi.dev.\n\t\tconst result = ((await this.models.refresh(refreshOptions)) as ModelsRefreshResult | undefined) ?? {\n\t\t\taborted: refreshOptions.signal?.aborted ?? false,\n\t\t\terrors: new Map(),\n\t\t};\n\t\tconst errors = new Map(result.errors);\n\t\tfor (const entry of live) {\n\t\t\tif (entry.status === \"error\" || entry.status === \"timeout\") {\n\t\t\t\terrors.set(entry.providerId, new Error(entry.error ?? entry.status));\n\t\t\t}\n\t\t}\n\t\tthis.updateModelSnapshot();\n\t\ttry {\n\t\t\tawait this.forceRefreshAvailability();\n\t\t} catch {\n\t\t\t// Availability errors are recorded by forceRefreshAvailability; refreshed models remain usable.\n\t\t}\n\t\tconst catalogResult: CatalogRefreshResult = {\n\t\t\taborted: result.aborted,\n\t\t\terrors,\n\t\t\tofficial,\n\t\t\tlive,\n\t\t\tincomplete: live.flatMap((entry) => entry.incomplete),\n\t\t};\n\t\tthis.lastCatalogRefresh = catalogResult;\n\t\treturn catalogResult;\n\t}\n\n\tgetLastCatalogRefresh(): CatalogRefreshResult {\n\t\treturn this.lastCatalogRefresh;\n\t}\n\n\tpersistUserModels(rows: readonly UserModelEntry[]): void {\n\t\tthis.userModels.upsert(rows);\n\t\tthis.overlay.setUser(this.userModelsForStoredProviders(this.snapshot.storedProviders));\n\t\tthis.updateModelSnapshot();\n\t}\n\n\tprivate async refreshOfficialCatalog(\n\t\tallowNetwork: boolean,\n\t\tsignal?: AbortSignal,\n\t): Promise<(OfficialCatalogLoadResult & { evictedUserRows: number }) | undefined> {\n\t\tconst storedProviders = await this.listStoredProviderIds();\n\t\tconst loaded = await loadOfficialCatalog({\n\t\t\tallowNetwork,\n\t\t\tcachePath: this.officialCachePath,\n\t\t\tsignal,\n\t\t\tproviderIds: [...storedProviders],\n\t\t});\n\t\tconst evicted = this.userModels.evictOfficial(officialModelKeys(loaded.catalog));\n\t\tconst templateByProvider = new Map<string, Model<Api> | undefined>();\n\t\tconst officialModels = loaded.catalog.models.map((entry) => {\n\t\t\tif (!templateByProvider.has(entry.provider)) {\n\t\t\t\ttemplateByProvider.set(entry.provider, this.bakedInModels(entry.provider)[0]);\n\t\t\t}\n\t\t\treturn officialEntryToModel(entry, templateByProvider.get(entry.provider));\n\t\t});\n\t\tthis.overlay.setOfficial(officialModels);\n\t\tthis.overlay.setUser(this.userModelsForStoredProviders(storedProviders));\n\t\treturn { ...loaded, evictedUserRows: evicted.length };\n\t}\n\n\tprivate async restoreLiveCatalogs(): Promise<LiveCatalogResult[]> {\n\t\tconst storedProviders = await this.listStoredProviderIds();\n\t\tconst results: LiveCatalogResult[] = [];\n\t\tfor (const providerId of LIVE_LIST_PROVIDER_IDS) {\n\t\t\tconst stored = storedProviders.has(providerId) ? await this.modelsStore.read(providerId) : undefined;\n\t\t\tif (stored?.models) this.overlay.setLive(providerId, stored.models);\n\t\t\telse this.overlay.setLive(providerId, []);\n\t\t\tresults.push({\n\t\t\t\tproviderId,\n\t\t\t\tstatus: \"skipped\",\n\t\t\t\tdiscoveries: [],\n\t\t\t\tadded: 0,\n\t\t\t\ttotal: stored?.models.length ?? 0,\n\t\t\t\tincomplete: [],\n\t\t\t});\n\t\t}\n\t\treturn results;\n\t}\n\n\tprivate async refreshLiveCatalogs(officialKeys: Set<string>, signal?: AbortSignal): Promise<LiveCatalogResult[]> {\n\t\tconst storedProviders = await this.listStoredProviderIds();\n\t\tconst known = knownModelKeys(\n\t\t\tLIVE_LIST_PROVIDER_IDS.flatMap((id) => this.bakedInModels(id)),\n\t\t\tofficialKeys,\n\t\t\tthis.userModels.keys(),\n\t\t);\n\n\t\tconst results = await Promise.all(\n\t\t\tLIVE_LIST_PROVIDER_IDS.map(async (providerId) => {\n\t\t\t\tif (!storedProviders.has(providerId)) {\n\t\t\t\t\tthis.overlay.setLive(providerId, []);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tproviderId,\n\t\t\t\t\t\tstatus: \"skipped\" as const,\n\t\t\t\t\t\tdiscoveries: [],\n\t\t\t\t\t\tadded: 0,\n\t\t\t\t\t\ttotal: 0,\n\t\t\t\t\t\tincomplete: [],\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst stored = await this.modelsStore.read(providerId);\n\t\t\t\tif (stored?.models) this.overlay.setLive(providerId, stored.models);\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tproviderId,\n\t\t\t\t\t\tstatus: \"skipped\" as const,\n\t\t\t\t\t\tdiscoveries: [],\n\t\t\t\t\t\tadded: 0,\n\t\t\t\t\t\ttotal: stored?.models.length ?? 0,\n\t\t\t\t\t\tincomplete: [],\n\t\t\t\t\t\terror: \"aborted\",\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst bakedIn = this.bakedInModels(providerId);\n\t\t\t\tconst provider = this.models.getProvider(providerId) ?? this.defaultBuiltins.get(providerId);\n\t\t\t\tconst baseUrl = provider?.baseUrl ?? bakedIn[0]?.baseUrl;\n\t\t\t\tif (!baseUrl) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tproviderId,\n\t\t\t\t\t\tstatus: \"skipped\" as const,\n\t\t\t\t\t\tdiscoveries: [],\n\t\t\t\t\t\tadded: 0,\n\t\t\t\t\t\ttotal: 0,\n\t\t\t\t\t\tincomplete: [],\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tlet credential: Credential | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tcredential = await this.refreshCredentialFor(providerId);\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tproviderId,\n\t\t\t\t\t\tstatus: \"error\" as const,\n\t\t\t\t\t\tdiscoveries: [],\n\t\t\t\t\t\tadded: 0,\n\t\t\t\t\t\ttotal: stored?.models.length ?? 0,\n\t\t\t\t\t\tincomplete: [],\n\t\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (!credential) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tproviderId,\n\t\t\t\t\t\tstatus: \"skipped\" as const,\n\t\t\t\t\t\tdiscoveries: [],\n\t\t\t\t\t\tadded: 0,\n\t\t\t\t\t\ttotal: stored?.models.length ?? 0,\n\t\t\t\t\t\tincomplete: [],\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst result = await fetchLiveProviderModels({\n\t\t\t\t\tproviderId,\n\t\t\t\t\tbaseUrl,\n\t\t\t\t\tbakedIn,\n\t\t\t\t\tcredential,\n\t\t\t\t\tknownKeys: known,\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\tif (result.status === \"ok\") {\n\t\t\t\t\tconst overlayModels = buildLiveOverlay(bakedIn, result.discoveries);\n\t\t\t\t\tthis.overlay.setLive(providerId, overlayModels);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.modelsStore.write(providerId, { models: overlayModels, checkedAt: Date.now() });\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Store write is best-effort.\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t}),\n\t\t);\n\t\treturn results;\n\t}\n\n\tprivate async refreshCredentialFor(providerId: string): Promise<Credential | undefined> {\n\t\tconst stored = await this.credentials.read(providerId);\n\t\t// Same lock + persist path as chat. Returning stored OAuth here skips\n\t\t// refresh and sends expired SuperGrok tokens to GET /models (HTTP 403).\n\t\tconst resolved = await this.getAuth(providerId);\n\t\tif (resolved?.auth.apiKey) return { type: \"api_key\", key: resolved.auth.apiKey, env: resolved.env };\n\t\tif (stored?.type === \"oauth\" && stored.access) return stored;\n\t\tif (stored?.type === \"api_key\" && stored.key) return stored;\n\t\treturn undefined;\n\t}\n\n\tregisterProvider(providerId: string, config: ProviderConfigInput): void {\n\t\t// Validate the incoming registration on its own, like the legacy registry:\n\t\t// a broken re-registration must throw without touching the stored config.\n\t\tvalidateExtensionProvider(providerId, this.builtins.get(providerId), this.config.getProvider(providerId), config);\n\t\t// Re-registration merges defined values over the previous registration and\n\t\t// preserves undefined ones, matching the legacy ModelRegistry contract.\n\t\tconst previous = this.extensionProviders.get(providerId);\n\t\tconst effective: ProviderConfigInput = { ...previous };\n\t\tfor (const [key, value] of Object.entries(config)) {\n\t\t\tif (value !== undefined) (effective as Record<string, unknown>)[key] = value;\n\t\t}\n\t\tthis.extensionProviders.set(providerId, effective);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tif (\n\t\t\tthis.snapshot.storedProviders.has(providerId) ||\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), effective)?.configured\n\t\t) {\n\t\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);\n\t\t\tconst auth = new Map(this.snapshot.auth);\n\t\t\t// Provisional entry until the async refresh lands; never clobber a real check result.\n\t\t\tif (!auth.get(providerId)) {\n\t\t\t\tauth.set(providerId, {\n\t\t\t\t\ttype: effective.oauth && !effective.apiKey ? \"oauth\" : \"api_key\",\n\t\t\t\t\tsource: \"configured provider\",\n\t\t\t\t});\n\t\t\t}\n\t\t\tthis.snapshot = {\n\t\t\t\t...this.snapshot,\n\t\t\t\tauth,\n\t\t\t\tconfiguredProviders,\n\t\t\t\tavailable: this.snapshot.all.filter((model) => configuredProviders.has(model.provider)),\n\t\t\t};\n\t\t}\n\t\tvoid this.refresh({ allowNetwork: false });\n\t}\n\n\tunregisterProvider(providerId: string): void {\n\t\tthis.extensionProviders.delete(providerId);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tvoid this.refresh({ allowNetwork: false });\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"model-runtime.js","sourceRoot":"","sources":["../../src/core/model-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAaN,YAAY,EACZ,UAAU,EAIV,WAAW,GAWX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,sBAAsB,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,WAAW,IAAI,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AACpF,OAAO,EACN,gBAAgB,EAChB,uBAAuB,EAEvB,sBAAsB,GAEtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EACN,mBAAmB,EAEnB,wBAAwB,EACxB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGN,oBAAoB,EACpB,2BAA2B,EAE3B,iCAAiC,EACjC,6BAA6B,EAC7B,yBAAyB,GACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,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EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;IAAA,CAC3C;CACD;AAED,+FAA+F;AAC/F,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAClD,OAA+D,EAC9B;IACjC,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC,oBAAoB,EAAE,CAAC;AAAA,CACtC","sourcesContent":["import { dirname, join } from \"node:path\";\nimport {\n\ttype Api,\n\ttype ApiStreamOptions,\n\ttype AssistantMessage,\n\ttype AssistantMessageEventStream,\n\ttype AuthCheck,\n\ttype AuthInteraction,\n\ttype AuthResult,\n\ttype AuthType,\n\ttype Context,\n\ttype Credential,\n\ttype CredentialInfo,\n\ttype CredentialStore,\n\tcreateModels,\n\tlazyStream,\n\ttype Model,\n\ttype Models,\n\ttype ModelsApiStreamOptions,\n\tModelsError,\n\ttype ModelsRefreshOptions,\n\ttype ModelsRefreshResult,\n\ttype ModelsSimpleStreamOptions,\n\ttype ModelsStore,\n\ttype ModelsStreamTransforms,\n\ttype MutableModels,\n\ttype Provider,\n\ttype ProviderHeaders,\n\ttype SimpleStreamOptions,\n\ttype StreamOptions,\n} from \"@ashx-j/lunr-ai\";\nimport * as builtinProviderCatalog from \"@ashx-j/lunr-ai/providers/all\";\nimport { getAgentDir } from \"../config.ts\";\nimport { AuthStorage as DefaultAuthStorage } from \"./auth-storage.ts\";\nimport { CatalogOverlaySource, knownModelKeys, withCatalogOverlay } from \"./catalog-merge.ts\";\nimport { readGrokCliXaiOAuth, wrapXaiGrokCliCredentials } from \"./grok-cli-auth.ts\";\nimport {\n\tbuildLiveOverlay,\n\tfetchLiveProviderModels,\n\ttype IncompleteLiveModel,\n\tLIVE_LIST_PROVIDER_IDS,\n\ttype LiveCatalogResult,\n} from \"./live-catalog.ts\";\nimport { ModelConfig } from \"./model-config.ts\";\nimport { FileModelsStore, InMemoryCodingAgentModelsStore } from \"./models-store.ts\";\nimport {\n\tloadOfficialCatalog,\n\ttype OfficialCatalogLoadResult,\n\tofficialCatalogCachePath,\n\tofficialEntryToModel,\n\tofficialModelKeys,\n\tpreferOfficialCatalog,\n} from \"./official-catalog.ts\";\nimport {\n\ttype AuthStatus,\n\ttype CompatibilityRequestConfig,\n\tcomposeModelProvider,\n\tconfiguredRequestAuthStatus,\n\ttype ProviderConfigInput,\n\tresolveCompatibilityRequestConfig,\n\tresolveConfiguredModelHeaders,\n\tvalidateExtensionProvider,\n} from \"./provider-composer.ts\";\nimport { RuntimeCredentials } from \"./runtime-credentials.ts\";\nimport { SubscriptionManager } from \"./subscriptions.ts\";\nimport { clearPlanUsageCache } from \"./usage-service.ts\";\nimport { type UserModelEntry, UserModelsStore, userEntryToModel, userModelsPath } from \"./user-models.ts\";\n\ninterface ModelRuntimeSnapshot {\n\tall: readonly Model<Api>[];\n\tavailable: readonly Model<Api>[];\n\tconfiguredProviders: ReadonlySet<string>;\n\tstoredProviders: ReadonlySet<string>;\n\tauth: ReadonlyMap<string, AuthCheck | undefined>;\n}\n\nexport interface CreateModelRuntimeOptions {\n\t/** Credential storage. Defaults to the file at authPath. */\n\tcredentials?: CredentialStore;\n\tauthPath?: string;\n\tmodelsPath?: string | null;\n\tmodelsStore?: ModelsStore;\n\tmodelsStorePath?: string;\n\tallowModelNetwork?: boolean;\n\t/** Applied by callers of `refresh()`, not by `create()` (startup is cache-only). */\n\tmodelRefreshTimeoutMs?: number;\n\t/** Unused. Kept so older callers compiling against this options bag still typecheck. */\n\tcatalogBaseUrl?: string;\n\t/** lunr: subscription-key pool. Defaults to subscriptions.json next to authPath (in-memory for custom stores). */\n\tsubscriptions?: SubscriptionManager;\n\t/**\n\t * Grok CLI home (`~/.grok`) used as a SuperGrok OAuth fallback.\n\t * `null` disables the fallback. Custom `credentials` default to disabled\n\t * unless this is an explicit path.\n\t */\n\tgrokHome?: string | null;\n}\n\nexport interface CatalogRefreshResult extends ModelsRefreshResult {\n\tofficial?: OfficialCatalogLoadResult & { evictedUserRows: number };\n\tlive: LiveCatalogResult[];\n\tincomplete: IncompleteLiveModel[];\n}\n\nexport interface ModelRuntimeAuthOverrides {\n\tapiKey?: string;\n\tenv?: Record<string, string>;\n}\n\nfunction mergeHeaders(\n\tbase: ProviderHeaders | undefined,\n\toverride: ProviderHeaders | undefined,\n): ProviderHeaders | undefined {\n\tif (!base && !override) return undefined;\n\tconst merged = { ...base };\n\tfor (const [name, value] of Object.entries(override ?? {})) {\n\t\tconst lowerName = name.toLowerCase();\n\t\tfor (const existingName of Object.keys(merged)) {\n\t\t\tif (existingName.toLowerCase() === lowerName) delete merged[existingName];\n\t\t}\n\t\tmerged[name] = value;\n\t}\n\treturn merged;\n}\n\n/** Configured pi-ai Models collection used by coding-agent and SDK consumers. */\nexport class ModelRuntime implements Models {\n\tprivate readonly models: MutableModels;\n\tprivate readonly credentials: RuntimeCredentials;\n\t/** lunr: per-provider subscription-key pools; rotation mirrors the active key into the credential store. */\n\treadonly subscriptionManager: SubscriptionManager;\n\tprivate readonly defaultBuiltins: ReadonlyMap<string, Provider>;\n\tprivate readonly builtins = new Map<string, Provider>();\n\tprivate readonly extensionProviders = new Map<string, ProviderConfigInput>();\n\tprivate readonly compositionErrors = new Map<string, string>();\n\tprivate readonly modelsPath: string | undefined;\n\tprivate readonly allowModelNetwork: boolean;\n\tprivate config: ModelConfig;\n\tprivate snapshot: ModelRuntimeSnapshot = {\n\t\tall: [],\n\t\tavailable: [],\n\t\tconfiguredProviders: new Set(),\n\t\tstoredProviders: new Set(),\n\t\tauth: new Map(),\n\t};\n\tprivate availabilityRefresh: Promise<void> | undefined;\n\tprivate availabilityError: string | undefined;\n\tprivate readonly modelsStore: ModelsStore;\n\tprivate readonly overlay = new CatalogOverlaySource();\n\tprivate readonly userModels: UserModelsStore;\n\tprivate readonly officialCachePath: string | undefined;\n\tprivate lastCatalogRefresh: CatalogRefreshResult = { aborted: false, errors: new Map(), live: [], incomplete: [] };\n\tprivate lastOfficial: OfficialCatalogLoadResult | undefined;\n\tprivate catalogRefresh: Promise<CatalogRefreshResult> | undefined;\n\tprivate catalogRefreshAllowsNetwork = false;\n\tprivate readonly grokHome: string | undefined;\n\n\tprivate constructor(\n\t\tcredentials: RuntimeCredentials,\n\t\tconfig: ModelConfig,\n\t\tmodelsPath: string | undefined,\n\t\tmodelsStore: ModelsStore,\n\t\tproviders: readonly Provider[],\n\t\tallowModelNetwork: boolean,\n\t\tsubscriptionManager: SubscriptionManager,\n\t\tcatalogDir: string | undefined,\n\t\tgrokHome: string | undefined,\n\t) {\n\t\tthis.credentials = credentials;\n\t\tthis.config = config;\n\t\tthis.modelsPath = modelsPath;\n\t\tthis.modelsStore = modelsStore;\n\t\tthis.allowModelNetwork = allowModelNetwork;\n\t\tthis.subscriptionManager = subscriptionManager;\n\t\tthis.userModels = new UserModelsStore(catalogDir ? userModelsPath(catalogDir) : undefined);\n\t\tthis.officialCachePath = catalogDir ? officialCatalogCachePath(catalogDir) : undefined;\n\t\tthis.grokHome = grokHome;\n\t\tthis.defaultBuiltins = new Map(providers.map((provider) => [provider.id, provider]));\n\t\tfor (const [providerId, provider] of this.defaultBuiltins) this.builtins.set(providerId, provider);\n\t\tthis.models = createModels({ credentials, modelsStore });\n\t\tthis.rebuildProviders();\n\t}\n\n\tstatic async create(options: CreateModelRuntimeOptions = {}): Promise<ModelRuntime> {\n\t\t// lunr: keep the underlying store — the SubscriptionManager mirrors rotated\n\t\t// keys into it directly, NOT through the RuntimeCredentials overlay (a runtime\n\t\t// --api-key override would shadow the mirror there).\n\t\tconst rawStore = options.credentials ?? DefaultAuthStorage.create(options.authPath);\n\t\tconst grokHomeDisabled =\n\t\t\toptions.grokHome === null || (options.grokHome === undefined && options.credentials !== undefined);\n\t\tconst grokHome = grokHomeDisabled ? undefined : (options.grokHome ?? undefined);\n\t\tconst baseStore = grokHomeDisabled ? rawStore : wrapXaiGrokCliCredentials(rawStore, { grokHome });\n\t\tconst credentials = new RuntimeCredentials(baseStore);\n\t\t// Pool persistence: subscriptions.json next to auth.json. A custom credential\n\t\t// store without an authPath (tests, SDK embeddings) gets a process-local pool\n\t\t// so nothing leaks into the real agent dir.\n\t\tconst subscriptionManager =\n\t\t\toptions.subscriptions ??\n\t\t\t(options.credentials && !options.authPath\n\t\t\t\t? SubscriptionManager.inMemory(baseStore)\n\t\t\t\t: SubscriptionManager.create(\n\t\t\t\t\t\tbaseStore,\n\t\t\t\t\t\toptions.authPath ? join(dirname(options.authPath), \"subscriptions.json\") : undefined,\n\t\t\t\t\t));\n\t\tconst modelsPath =\n\t\t\toptions.modelsPath === null ? undefined : (options.modelsPath ?? join(getAgentDir(), \"models.json\"));\n\t\tconst config = await ModelConfig.load(modelsPath);\n\t\tconst modelsStore =\n\t\t\toptions.modelsStore ??\n\t\t\t(modelsPath\n\t\t\t\t? new FileModelsStore(options.modelsStorePath ?? join(dirname(modelsPath), \"models-store.json\"))\n\t\t\t\t: new InMemoryCodingAgentModelsStore());\n\t\tconst providers = builtinProviderCatalog.builtinProviders();\n\t\tconst catalogDir = modelsPath ? dirname(modelsPath) : options.authPath ? dirname(options.authPath) : undefined;\n\t\tconst runtime = new ModelRuntime(\n\t\t\tcredentials,\n\t\t\tconfig,\n\t\t\tmodelsPath,\n\t\t\tmodelsStore,\n\t\t\tproviders,\n\t\t\toptions.allowModelNetwork ?? process.env.PI_OFFLINE === undefined,\n\t\t\tsubscriptionManager,\n\t\t\tcatalogDir,\n\t\t\tgrokHome,\n\t\t);\n\t\truntime.configureRadiusProviders();\n\t\truntime.rebuildProviders();\n\t\t// lunr: create() must not wait on GitHub / provider /v1/models / a dead NIC.\n\t\t// Disk cache + baked-in + bundled official overlay are enough to start;\n\t\t// /refresh and the model picker still do a live refresh.\n\t\tawait runtime.refresh({ allowNetwork: false });\n\t\treturn runtime;\n\t}\n\n\tprivate configureRadiusProviders(): void {\n\t\tthis.builtins.clear();\n\t\tfor (const [providerId, provider] of this.defaultBuiltins) this.builtins.set(providerId, provider);\n\t\tfor (const providerId of this.config.getProviderIds()) {\n\t\t\tconst config = this.config.getProvider(providerId);\n\t\t\tif (config?.oauth !== \"radius\" || !config.baseUrl) continue;\n\t\t\tthis.builtins.set(\n\t\t\t\tproviderId,\n\t\t\t\tbuiltinProviderCatalog.radiusProvider({\n\t\t\t\t\tid: providerId,\n\t\t\t\t\tname: config.name ?? providerId,\n\t\t\t\t\tgateway: config.baseUrl.replace(/\\/v1\\/?$/u, \"\"),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate providerIds(): Set<string> {\n\t\treturn new Set([...this.builtins.keys(), ...this.config.getProviderIds(), ...this.extensionProviders.keys()]);\n\t}\n\n\tprivate recomposeProvider(providerId: string): void {\n\t\tconst base = this.builtins.get(providerId);\n\t\tconst extension = this.extensionProviders.get(providerId);\n\t\tif (!base && !this.config.getProvider(providerId) && !extension) {\n\t\t\tthis.models.deleteProvider(providerId);\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn;\n\t\t}\n\t\tif (base && !this.config.getProvider(providerId) && !extension) {\n\t\t\t// No models.json/extension overlays: keep builtin auth/stream exact, then apply catalog layers.\n\t\t\tthis.models.setProvider(this.withLocalCatalog(base));\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tthis.models.setProvider(this.withLocalCatalog(composeModelProvider(providerId, base, this.config, extension)));\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t} catch (error) {\n\t\t\tthis.compositionErrors.set(providerId, error instanceof Error ? error.message : String(error));\n\t\t\tif (base) this.models.setProvider(this.withLocalCatalog(base));\n\t\t\telse this.models.deleteProvider(providerId);\n\t\t}\n\t}\n\n\tprivate withLocalCatalog(provider: Provider): Provider {\n\t\treturn withCatalogOverlay(provider, this.overlay);\n\t}\n\n\tprivate bakedInModels(providerId: string): Model<Api>[] {\n\t\treturn [...(this.defaultBuiltins.get(providerId)?.getModels() ?? [])];\n\t}\n\n\tprivate rebuildProviders(): void {\n\t\tthis.models.clearProviders();\n\t\tthis.compositionErrors.clear();\n\t\tfor (const providerId of this.providerIds()) this.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t}\n\n\tprivate updateModelSnapshot(): void {\n\t\tconst all = [...this.models.getModels()];\n\t\tthis.snapshot = {\n\t\t\t...this.snapshot,\n\t\t\tall,\n\t\t\tavailable: all.filter((model) => this.snapshot.configuredProviders.has(model.provider)),\n\t\t};\n\t}\n\n\tprivate async listStoredProviderIds(): Promise<Set<string>> {\n\t\tconst credentials = await this.credentials.list();\n\t\treturn new Set(credentials.map((entry) => entry.providerId));\n\t}\n\n\t/** `/model` lists stored creds + models.json/extension keys, never ambient envApiKeyAuth. */\n\tprivate configuredProviderIds(storedProviders: ReadonlySet<string>): Set<string> {\n\t\tconst configured = new Set(storedProviders);\n\t\tfor (const provider of this.models.getProviders()) {\n\t\t\tif (\n\t\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(provider.id), this.extensionProviders.get(provider.id))\n\t\t\t\t\t?.configured\n\t\t\t) {\n\t\t\t\tconfigured.add(provider.id);\n\t\t\t}\n\t\t}\n\t\treturn configured;\n\t}\n\n\tprivate userModelsForStoredProviders(storedProviders: ReadonlySet<string>): Model<Api>[] {\n\t\treturn this.userModels\n\t\t\t.list()\n\t\t\t.filter((row) => storedProviders.has(row.provider))\n\t\t\t.map(userEntryToModel);\n\t}\n\n\tprivate async runAvailabilityRefresh(): Promise<void> {\n\t\tconst providers = this.models.getProviders();\n\t\tconst [available, checks, storedProviders] = await Promise.all([\n\t\t\tthis.models.getAvailable(),\n\t\t\tPromise.all(\n\t\t\t\tproviders.map(\n\t\t\t\t\tasync (provider): Promise<[string, AuthCheck | undefined]> => [\n\t\t\t\t\t\tprovider.id,\n\t\t\t\t\t\tawait this.models.checkAuth(provider.id),\n\t\t\t\t\t],\n\t\t\t\t),\n\t\t\t),\n\t\t\tthis.listStoredProviderIds(),\n\t\t]);\n\t\tconst auth = new Map(checks);\n\t\tconst configuredProviders = this.configuredProviderIds(storedProviders);\n\t\tthis.snapshot = {\n\t\t\tall: [...this.models.getModels()],\n\t\t\tavailable: available.filter((model) => configuredProviders.has(model.provider)),\n\t\t\tconfiguredProviders,\n\t\t\tstoredProviders,\n\t\t\tauth,\n\t\t};\n\t\tthis.availabilityError = undefined;\n\t}\n\n\tprivate queueAvailabilityRefresh(after: Promise<void> | undefined): Promise<void> {\n\t\tconst refresh = (after ?? Promise.resolve()).catch(() => {}).then(() => this.runAvailabilityRefresh());\n\t\tconst recorded = refresh.catch((error) => {\n\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\tthrow error;\n\t\t});\n\t\tconst tracked = recorded.finally(() => {\n\t\t\tif (this.availabilityRefresh === tracked) this.availabilityRefresh = undefined;\n\t\t});\n\t\tthis.availabilityRefresh = tracked;\n\t\treturn tracked;\n\t}\n\n\t/** Coalesce concurrent readers onto the pending refresh. */\n\tprivate refreshAvailability(): Promise<void> {\n\t\treturn this.availabilityRefresh ?? this.queueAvailabilityRefresh(undefined);\n\t}\n\n\t/** Mutations must not observe an in-flight refresh started before them. */\n\tprivate forceRefreshAvailability(): Promise<void> {\n\t\treturn this.queueAvailabilityRefresh(this.availabilityRefresh);\n\t}\n\n\tgetProviders(): readonly Provider[] {\n\t\treturn this.models.getProviders();\n\t}\n\n\tgetProvider(providerId: string): Provider | undefined {\n\t\treturn this.models.getProvider(providerId);\n\t}\n\n\tgetModels(providerId?: string): readonly Model<Api>[] {\n\t\treturn this.models.getModels(providerId);\n\t}\n\n\tgetModel(providerId: string, modelId: string): Model<Api> | undefined {\n\t\treturn this.models.getModel(providerId, modelId);\n\t}\n\n\tasync checkAuth(providerId: string): Promise<AuthCheck | undefined> {\n\t\treturn this.models.checkAuth(providerId);\n\t}\n\n\tasync getAvailable(providerId?: string): Promise<readonly Model<Api>[]> {\n\t\tif (providerId) {\n\t\t\tif (this.availabilityRefresh) {\n\t\t\t\tawait this.availabilityRefresh;\n\t\t\t\treturn this.snapshot.available.filter((model) => model.provider === providerId);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\treturn await this.models.getAvailable(providerId);\n\t\t\t} catch (error) {\n\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tawait this.refreshAvailability();\n\t\treturn this.snapshot.available;\n\t}\n\n\tgetAvailableSnapshot(): readonly Model<Api>[] {\n\t\treturn this.snapshot.available;\n\t}\n\n\tgetError(): string | undefined {\n\t\tconst errors: string[] = [];\n\t\tconst configError = this.config.getError();\n\t\tif (configError) errors.push(configError);\n\t\tfor (const [providerId, error] of this.compositionErrors) {\n\t\t\terrors.push(`Provider \"${providerId}\": ${error}`);\n\t\t}\n\t\tif (this.availabilityError) errors.push(`Availability refresh: ${this.availabilityError}`);\n\t\treturn errors.length > 0 ? errors.join(\"\\n\\n\") : undefined;\n\t}\n\n\tgetRegisteredProviderConfig(providerId: string): ProviderConfigInput | undefined {\n\t\treturn this.extensionProviders.get(providerId);\n\t}\n\n\tgetRegisteredProviderIds(): readonly string[] {\n\t\treturn [...this.extensionProviders.keys()];\n\t}\n\n\t/** @internal Compatibility fallback for ModelRegistry when provider auth is unconfigured. */\n\tgetCompatibilityRequestConfig(model: Model<Api>): CompatibilityRequestConfig {\n\t\treturn resolveCompatibilityRequestConfig(\n\t\t\tmodel,\n\t\t\tthis.config.getProvider(model.provider),\n\t\t\tthis.extensionProviders.get(model.provider),\n\t\t);\n\t}\n\n\tisUsingOAuth(providerId: string): boolean {\n\t\treturn this.snapshot.auth.get(providerId)?.type === \"oauth\";\n\t}\n\n\thasConfiguredAuth(providerId: string): boolean {\n\t\treturn this.snapshot.configuredProviders.has(providerId);\n\t}\n\n\tgetAuth(providerId: string, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: Model<Api>, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tasync getAuth(\n\t\tproviderOrModel: string | Model<Api>,\n\t\toverrides: ModelRuntimeAuthOverrides = {},\n\t): Promise<AuthResult | undefined> {\n\t\tif (typeof providerOrModel === \"string\") return this.models.getAuth(providerOrModel, overrides);\n\t\tconst resolution = await this.models.getAuth(providerOrModel, overrides);\n\t\tif (!resolution) return undefined;\n\t\tconst configuredHeaders = resolveConfiguredModelHeaders(\n\t\t\tproviderOrModel,\n\t\t\tthis.config.getProvider(providerOrModel.provider),\n\t\t\tthis.extensionProviders.get(providerOrModel.provider),\n\t\t\t{ ...(resolution.env ?? {}), ...(overrides.env ?? {}) },\n\t\t);\n\t\treturn {\n\t\t\t...resolution,\n\t\t\tauth: {\n\t\t\t\t...resolution.auth,\n\t\t\t\theaders: mergeHeaders(resolution.auth.headers, configuredHeaders),\n\t\t\t},\n\t\t};\n\t}\n\n\t/** lunr: whether a runtime --api-key override is active for the provider (it shadows auth.json). */\n\thasRuntimeApiKey(providerId: string): boolean {\n\t\treturn this.credentials.hasRuntimeApiKey(providerId);\n\t}\n\n\tasync setRuntimeApiKey(\n\t\tproviderId: string,\n\t\tapiKey: string,\n\t\toptions?: { allowNetwork?: boolean },\n\t): Promise<void> {\n\t\tthis.credentials.setRuntimeApiKey(providerId, apiKey);\n\t\tconst auth = new Map(this.snapshot.auth).set(providerId, { type: \"api_key\", source: \"runtime API key\" });\n\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);\n\t\tconst storedProviders = new Set(this.snapshot.storedProviders).add(providerId);\n\t\tthis.snapshot = {\n\t\t\t...this.snapshot,\n\t\t\tauth,\n\t\t\tconfiguredProviders,\n\t\t\tstoredProviders,\n\t\t\tavailable: this.snapshot.all.filter((model) => configuredProviders.has(model.provider)),\n\t\t};\n\t\tawait this.refresh({ allowNetwork: options?.allowNetwork ?? this.allowModelNetwork });\n\t}\n\n\tasync removeRuntimeApiKey(providerId: string): Promise<void> {\n\t\tthis.credentials.removeRuntimeApiKey(providerId);\n\t\tawait this.refresh({ allowNetwork: this.allowModelNetwork });\n\t}\n\n\t/** lunr: whether network model-catalog fetches are allowed (offline mode disables them). */\n\tisNetworkAllowed(): boolean {\n\t\treturn this.allowModelNetwork;\n\t}\n\n\tlistCredentials(): Promise<readonly CredentialInfo[]> {\n\t\treturn this.credentials.list();\n\t}\n\n\tgetProviderAuthStatus(providerId: string): AuthStatus {\n\t\tif (this.credentials.hasRuntimeApiKey(providerId)) return { configured: true, source: \"runtime\" };\n\t\tif (this.snapshot.storedProviders.has(providerId)) return { configured: true, source: \"stored\" };\n\t\tconst configured = configuredRequestAuthStatus(\n\t\t\tthis.config.getProvider(providerId),\n\t\t\tthis.extensionProviders.get(providerId),\n\t\t);\n\t\tif (configured) return configured;\n\t\tconst check = this.snapshot.auth.get(providerId);\n\t\treturn check ? { configured: true, source: \"environment\", label: check.source } : { configured: false };\n\t}\n\n\tprivate async prepareRequest(\n\t\tmodel: Model<Api>,\n\t\toptions: (StreamOptions & ModelsStreamTransforms) | undefined,\n\t): Promise<{ provider: Provider; model: Model<Api>; options: StreamOptions }> {\n\t\tconst provider = this.models.getProvider(model.provider);\n\t\tif (!provider) throw new ModelsError(\"provider\", `Unknown provider: ${model.provider}`);\n\t\tconst resolution = await this.getAuth(model, { apiKey: options?.apiKey, env: options?.env });\n\t\tif (!resolution) throw new ModelsError(\"auth\", `Provider is not configured: ${model.provider}`);\n\n\t\tconst { transformHeaders, ...providerOptions } = options ?? {};\n\t\tlet headers = mergeHeaders(resolution.auth.headers, providerOptions.headers);\n\t\tif (transformHeaders) headers = await transformHeaders(headers ?? {});\n\t\tconst env =\n\t\t\tresolution.env || providerOptions.env\n\t\t\t\t? { ...(resolution.env ?? {}), ...(providerOptions.env ?? {}) }\n\t\t\t\t: undefined;\n\t\treturn {\n\t\t\tprovider,\n\t\t\tmodel: resolution.auth.baseUrl ? { ...model, baseUrl: resolution.auth.baseUrl } : model,\n\t\t\toptions: {\n\t\t\t\t...providerOptions,\n\t\t\t\tapiKey: providerOptions.apiKey ?? resolution.auth.apiKey,\n\t\t\t\theaders,\n\t\t\t\tenv,\n\t\t\t},\n\t\t};\n\t}\n\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream {\n\t\treturn lazyStream(model, async () => {\n\t\t\tconst prepared = await this.prepareRequest(\n\t\t\t\tmodel,\n\t\t\t\toptions as (StreamOptions & ModelsStreamTransforms) | undefined,\n\t\t\t);\n\t\t\treturn prepared.provider.stream(\n\t\t\t\tprepared.model as Model<TApi>,\n\t\t\t\tcontext,\n\t\t\t\tprepared.options as ApiStreamOptions<TApi>,\n\t\t\t);\n\t\t});\n\t}\n\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.stream(model, context, options).result();\n\t}\n\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream {\n\t\treturn lazyStream(model, async () => {\n\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\treturn prepared.provider.streamSimple(prepared.model, context, prepared.options as SimpleStreamOptions);\n\t\t});\n\t}\n\n\tcompleteSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage> {\n\t\treturn this.streamSimple(model, context, options).result();\n\t}\n\n\tasync login(providerId: string, type: AuthType, interaction: AuthInteraction): Promise<Credential> {\n\t\tconst credential = await this.models.login(providerId, type, interaction);\n\t\tclearPlanUsageCache();\n\t\tawait this.refresh({ allowNetwork: this.allowModelNetwork });\n\t\treturn credential;\n\t}\n\n\tasync logout(providerId: string): Promise<void> {\n\t\tawait this.models.logout(providerId);\n\t\tawait this.modelsStore.delete(providerId);\n\t\tthis.userModels.evictProvider(providerId);\n\t\tthis.overlay.setLive(providerId, []);\n\t\t// Reset credential-dependent compatibility projections before the unconfigured provider is skipped by refresh.\n\t\tthis.recomposeProvider(providerId);\n\t\tclearPlanUsageCache();\n\t\tawait this.refresh({ allowNetwork: this.allowModelNetwork });\n\t}\n\n\t/** Copy a live Grok CLI SuperGrok session into lunR `auth.json`. */\n\tasync importGrokCliXaiAuth(): Promise<Credential | undefined> {\n\t\tconst grok = readGrokCliXaiOAuth({ grokHome: this.grokHome });\n\t\tif (!grok) return undefined;\n\t\tconst stored = await this.credentials.modify(\"xai\", async () => grok);\n\t\tclearPlanUsageCache();\n\t\tawait this.refresh({ allowNetwork: this.allowModelNetwork });\n\t\treturn stored;\n\t}\n\n\tasync reloadConfig(): Promise<void> {\n\t\tthis.config = await ModelConfig.load(this.modelsPath);\n\t\tthis.configureRadiusProviders();\n\t\tthis.rebuildProviders();\n\t\tawait this.refresh({ allowNetwork: this.allowModelNetwork });\n\t}\n\n\tasync refresh(options: ModelsRefreshOptions = {}): Promise<CatalogRefreshResult> {\n\t\tconst allowNetwork = options.allowNetwork ?? this.allowModelNetwork;\n\t\tif (this.catalogRefresh) {\n\t\t\t// Join an in-flight refresh that is at least as capable. A cache-only\n\t\t\t// flight must not swallow a later network refresh.\n\t\t\tif (this.catalogRefreshAllowsNetwork || !allowNetwork) {\n\t\t\t\treturn this.catalogRefresh;\n\t\t\t}\n\t\t\tawait this.catalogRefresh.catch(() => {});\n\t\t\treturn this.refresh({ ...options, allowNetwork });\n\t\t}\n\n\t\tconst run = this.executeCatalogRefresh({ ...options, allowNetwork }).finally(() => {\n\t\t\tif (this.catalogRefresh === run) {\n\t\t\t\tthis.catalogRefresh = undefined;\n\t\t\t\tthis.catalogRefreshAllowsNetwork = false;\n\t\t\t}\n\t\t});\n\t\tthis.catalogRefresh = run;\n\t\tthis.catalogRefreshAllowsNetwork = allowNetwork;\n\t\treturn run;\n\t}\n\n\tprivate async executeCatalogRefresh(\n\t\trefreshOptions: ModelsRefreshOptions & { allowNetwork: boolean },\n\t): Promise<CatalogRefreshResult> {\n\t\tconst official = await this.refreshOfficialCatalog(refreshOptions.allowNetwork, refreshOptions.signal);\n\t\tconst live = refreshOptions.allowNetwork\n\t\t\t? await this.refreshLiveCatalogs(\n\t\t\t\t\tofficial ? officialModelKeys(official.catalog) : new Set(),\n\t\t\t\t\trefreshOptions.signal,\n\t\t\t\t)\n\t\t\t: await this.restoreLiveCatalogs();\n\n\t\t// Radius / local-provider / extension refreshModels hooks. Live-list\n\t\t// providers have no refreshModels, so this does not hit pi.dev.\n\t\tconst result = ((await this.models.refresh(refreshOptions)) as ModelsRefreshResult | undefined) ?? {\n\t\t\taborted: refreshOptions.signal?.aborted ?? false,\n\t\t\terrors: new Map(),\n\t\t};\n\t\tconst errors = new Map(result.errors);\n\t\tfor (const entry of live) {\n\t\t\tif (entry.status === \"error\" || entry.status === \"timeout\") {\n\t\t\t\terrors.set(entry.providerId, new Error(entry.error ?? entry.status));\n\t\t\t}\n\t\t}\n\t\tthis.updateModelSnapshot();\n\t\ttry {\n\t\t\tawait this.forceRefreshAvailability();\n\t\t} catch {\n\t\t\t// Availability errors are recorded by forceRefreshAvailability; refreshed models remain usable.\n\t\t}\n\t\tconst catalogResult: CatalogRefreshResult = {\n\t\t\taborted: result.aborted,\n\t\t\terrors,\n\t\t\tofficial,\n\t\t\tlive,\n\t\t\tincomplete: live.flatMap((entry) => entry.incomplete),\n\t\t};\n\t\tthis.lastCatalogRefresh = catalogResult;\n\t\treturn catalogResult;\n\t}\n\n\tgetLastCatalogRefresh(): CatalogRefreshResult {\n\t\treturn this.lastCatalogRefresh;\n\t}\n\n\tpersistUserModels(rows: readonly UserModelEntry[]): void {\n\t\tthis.userModels.upsert(rows);\n\t\tthis.overlay.setUser(this.userModelsForStoredProviders(this.snapshot.storedProviders));\n\t\tthis.updateModelSnapshot();\n\t}\n\n\tprivate async refreshOfficialCatalog(\n\t\tallowNetwork: boolean,\n\t\tsignal?: AbortSignal,\n\t): Promise<(OfficialCatalogLoadResult & { evictedUserRows: number }) | undefined> {\n\t\tconst storedProviders = await this.listStoredProviderIds();\n\t\tconst loaded = preferOfficialCatalog(\n\t\t\tthis.lastOfficial,\n\t\t\tawait loadOfficialCatalog({\n\t\t\t\tallowNetwork,\n\t\t\t\tcachePath: this.officialCachePath,\n\t\t\t\tsignal,\n\t\t\t\tproviderIds: [...storedProviders],\n\t\t\t}),\n\t\t);\n\t\tthis.lastOfficial = loaded;\n\t\tconst evicted = this.userModels.evictOfficial(officialModelKeys(loaded.catalog));\n\t\tconst templateByProvider = new Map<string, Model<Api> | undefined>();\n\t\tconst officialModels = loaded.catalog.models\n\t\t\t.filter((entry) => storedProviders.has(entry.provider))\n\t\t\t.map((entry) => {\n\t\t\t\tif (!templateByProvider.has(entry.provider)) {\n\t\t\t\t\ttemplateByProvider.set(entry.provider, this.bakedInModels(entry.provider)[0]);\n\t\t\t\t}\n\t\t\t\treturn officialEntryToModel(entry, templateByProvider.get(entry.provider));\n\t\t\t});\n\t\tthis.overlay.setOfficial(officialModels);\n\t\tthis.overlay.setUser(this.userModelsForStoredProviders(storedProviders));\n\t\treturn { ...loaded, evictedUserRows: evicted.length };\n\t}\n\n\tprivate async restoreLiveCatalogs(): Promise<LiveCatalogResult[]> {\n\t\tconst storedProviders = await this.listStoredProviderIds();\n\t\tconst results: LiveCatalogResult[] = [];\n\t\tfor (const providerId of LIVE_LIST_PROVIDER_IDS) {\n\t\t\tconst stored = storedProviders.has(providerId) ? await this.modelsStore.read(providerId) : undefined;\n\t\t\tif (stored?.models) this.overlay.setLive(providerId, stored.models);\n\t\t\telse this.overlay.setLive(providerId, []);\n\t\t\tresults.push({\n\t\t\t\tproviderId,\n\t\t\t\tstatus: \"skipped\",\n\t\t\t\tdiscoveries: [],\n\t\t\t\tadded: 0,\n\t\t\t\ttotal: stored?.models.length ?? 0,\n\t\t\t\tincomplete: [],\n\t\t\t});\n\t\t}\n\t\treturn results;\n\t}\n\n\tprivate async refreshLiveCatalogs(officialKeys: Set<string>, signal?: AbortSignal): Promise<LiveCatalogResult[]> {\n\t\tconst storedProviders = await this.listStoredProviderIds();\n\t\tconst known = knownModelKeys(\n\t\t\tLIVE_LIST_PROVIDER_IDS.flatMap((id) => this.bakedInModels(id)),\n\t\t\tofficialKeys,\n\t\t\tthis.userModels.keys(),\n\t\t);\n\n\t\tconst results = await Promise.all(\n\t\t\tLIVE_LIST_PROVIDER_IDS.map(async (providerId) => {\n\t\t\t\tif (!storedProviders.has(providerId)) {\n\t\t\t\t\tthis.overlay.setLive(providerId, []);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tproviderId,\n\t\t\t\t\t\tstatus: \"skipped\" as const,\n\t\t\t\t\t\tdiscoveries: [],\n\t\t\t\t\t\tadded: 0,\n\t\t\t\t\t\ttotal: 0,\n\t\t\t\t\t\tincomplete: [],\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst stored = await this.modelsStore.read(providerId);\n\t\t\t\tif (stored?.models) this.overlay.setLive(providerId, stored.models);\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tproviderId,\n\t\t\t\t\t\tstatus: \"skipped\" as const,\n\t\t\t\t\t\tdiscoveries: [],\n\t\t\t\t\t\tadded: 0,\n\t\t\t\t\t\ttotal: stored?.models.length ?? 0,\n\t\t\t\t\t\tincomplete: [],\n\t\t\t\t\t\terror: \"aborted\",\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst bakedIn = this.bakedInModels(providerId);\n\t\t\t\tconst provider = this.models.getProvider(providerId) ?? this.defaultBuiltins.get(providerId);\n\t\t\t\tconst baseUrl = provider?.baseUrl ?? bakedIn[0]?.baseUrl;\n\t\t\t\tif (!baseUrl) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tproviderId,\n\t\t\t\t\t\tstatus: \"skipped\" as const,\n\t\t\t\t\t\tdiscoveries: [],\n\t\t\t\t\t\tadded: 0,\n\t\t\t\t\t\ttotal: 0,\n\t\t\t\t\t\tincomplete: [],\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tlet credential: Credential | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tcredential = await this.refreshCredentialFor(providerId);\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tproviderId,\n\t\t\t\t\t\tstatus: \"error\" as const,\n\t\t\t\t\t\tdiscoveries: [],\n\t\t\t\t\t\tadded: 0,\n\t\t\t\t\t\ttotal: stored?.models.length ?? 0,\n\t\t\t\t\t\tincomplete: [],\n\t\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (!credential) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tproviderId,\n\t\t\t\t\t\tstatus: \"skipped\" as const,\n\t\t\t\t\t\tdiscoveries: [],\n\t\t\t\t\t\tadded: 0,\n\t\t\t\t\t\ttotal: stored?.models.length ?? 0,\n\t\t\t\t\t\tincomplete: [],\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst result = await fetchLiveProviderModels({\n\t\t\t\t\tproviderId,\n\t\t\t\t\tbaseUrl,\n\t\t\t\t\tbakedIn,\n\t\t\t\t\tcredential,\n\t\t\t\t\tknownKeys: known,\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\tif (result.status === \"ok\") {\n\t\t\t\t\tconst overlayModels = buildLiveOverlay(bakedIn, result.discoveries);\n\t\t\t\t\tthis.overlay.setLive(providerId, overlayModels);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.modelsStore.write(providerId, { models: overlayModels, checkedAt: Date.now() });\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Store write is best-effort.\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t}),\n\t\t);\n\t\treturn results;\n\t}\n\n\tprivate async refreshCredentialFor(providerId: string): Promise<Credential | undefined> {\n\t\tconst stored = await this.credentials.read(providerId);\n\t\t// Same lock + persist path as chat. Returning stored OAuth here skips\n\t\t// refresh and sends expired SuperGrok tokens to GET /models (HTTP 403).\n\t\tconst resolved = await this.getAuth(providerId);\n\t\tif (resolved?.auth.apiKey) return { type: \"api_key\", key: resolved.auth.apiKey, env: resolved.env };\n\t\tif (stored?.type === \"oauth\" && stored.access) return stored;\n\t\tif (stored?.type === \"api_key\" && stored.key) return stored;\n\t\treturn undefined;\n\t}\n\n\tregisterProvider(providerId: string, config: ProviderConfigInput): void {\n\t\t// Validate the incoming registration on its own, like the legacy registry:\n\t\t// a broken re-registration must throw without touching the stored config.\n\t\tvalidateExtensionProvider(providerId, this.builtins.get(providerId), this.config.getProvider(providerId), config);\n\t\t// Re-registration merges defined values over the previous registration and\n\t\t// preserves undefined ones, matching the legacy ModelRegistry contract.\n\t\tconst previous = this.extensionProviders.get(providerId);\n\t\tconst effective: ProviderConfigInput = { ...previous };\n\t\tfor (const [key, value] of Object.entries(config)) {\n\t\t\tif (value !== undefined) (effective as Record<string, unknown>)[key] = value;\n\t\t}\n\t\tthis.extensionProviders.set(providerId, effective);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tif (\n\t\t\tthis.snapshot.storedProviders.has(providerId) ||\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), effective)?.configured\n\t\t) {\n\t\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);\n\t\t\tconst auth = new Map(this.snapshot.auth);\n\t\t\t// Provisional entry until the async refresh lands; never clobber a real check result.\n\t\t\tif (!auth.get(providerId)) {\n\t\t\t\tauth.set(providerId, {\n\t\t\t\t\ttype: effective.oauth && !effective.apiKey ? \"oauth\" : \"api_key\",\n\t\t\t\t\tsource: \"configured provider\",\n\t\t\t\t});\n\t\t\t}\n\t\t\tthis.snapshot = {\n\t\t\t\t...this.snapshot,\n\t\t\t\tauth,\n\t\t\t\tconfiguredProviders,\n\t\t\t\tavailable: this.snapshot.all.filter((model) => configuredProviders.has(model.provider)),\n\t\t\t};\n\t\t}\n\t\tvoid this.refresh({ allowNetwork: false });\n\t}\n\n\tunregisterProvider(providerId: string): void {\n\t\tthis.extensionProviders.delete(providerId);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tvoid this.refresh({ allowNetwork: false });\n\t}\n}\n\n/** TUI init / footer / rebind: cache-only. Live refresh is `/refresh` and the model picker. */\nexport async function refreshModelCandidatesForInit(\n\truntime: Pick<ModelRuntime, \"refresh\" | \"getAvailableSnapshot\">,\n): Promise<readonly Model<Api>[]> {\n\tawait runtime.refresh({ allowNetwork: false });\n\treturn runtime.getAvailableSnapshot();\n}\n"]}
|
|
@@ -49,6 +49,12 @@ export declare function loadBundledOfficialCatalog(): OfficialCatalogFile;
|
|
|
49
49
|
export declare function loadCachedOfficialCatalog(cachePath?: string): OfficialCatalogFile | undefined;
|
|
50
50
|
export declare function writeOfficialCatalogCache(catalog: OfficialCatalogFile, cachePath: string): void;
|
|
51
51
|
export declare function officialModelsByProvider(catalog: OfficialCatalogFile): Map<string, OfficialModelEntry[]>;
|
|
52
|
+
/** Replace or add per-provider rows. Existing providers not in `replacements` are kept. */
|
|
53
|
+
export declare function mergeOfficialCatalogByProvider(base: OfficialCatalogFile, replacements: ReadonlyMap<string, OfficialModelEntry[]>, updatedAt?: string): OfficialCatalogFile;
|
|
54
|
+
/** Bundled as the floor; cache rows win per provider. */
|
|
55
|
+
export declare function officialCatalogBase(bundled: OfficialCatalogFile, cachePath?: string): OfficialCatalogFile;
|
|
56
|
+
/** A completed GitHub overlay must not be replaced by cache/bundled. */
|
|
57
|
+
export declare function preferOfficialCatalog(previous: OfficialCatalogLoadResult | undefined, next: OfficialCatalogLoadResult): OfficialCatalogLoadResult;
|
|
52
58
|
export declare function officialModelKeys(catalog: OfficialCatalogFile): Set<string>;
|
|
53
59
|
export declare function officialEntryToModel(entry: OfficialModelEntry, template?: Model<Api>): Model<Api>;
|
|
54
60
|
export interface LoadOfficialCatalogOptions {
|
|
@@ -66,7 +72,8 @@ export interface LoadOfficialCatalogOptions {
|
|
|
66
72
|
/**
|
|
67
73
|
* Load the official overlay. Network only when allowNetwork is true.
|
|
68
74
|
* Fetches providers.json, then providers/{id}.json for stored-credential providers.
|
|
69
|
-
*
|
|
75
|
+
* Successful shards replace that provider only; failed shards keep cache/bundled rows.
|
|
76
|
+
* All requested shards failed → cache, then bundled. Never writes a worse cache. Never throws.
|
|
70
77
|
*/
|
|
71
78
|
export declare function loadOfficialCatalog(options?: LoadOfficialCatalogOptions): Promise<OfficialCatalogLoadResult>;
|
|
72
79
|
//# sourceMappingURL=official-catalog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"official-catalog.d.ts","sourceRoot":"","sources":["../../src/core/official-catalog.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAI1E,qHAAqH;AACrH,eAAO,MAAM,4BAA4B,iEAAiE,CAAC;AAC3G,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAChD,eAAO,MAAM,+BAA+B,gCAAgC,CAAC;AAK7E,MAAM,WAAW,iBAAiB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IAC5B,IAAI,EAAE,iBAAiB,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC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B,CAAC,OAAO,EAAE,mBAAmB,GAAG,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC,CAQxG;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,GAAG,GAAG,CAAC,MAAM,CAAC,CAE3E;AAID,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,kBAAkB,EAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAgBjG;AAED,MAAM,WAAW,0BAA0B;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,sDAAsD;IACtD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,qEAAqE;IACrE,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAChC;AAiDD;;;;GAIG;AACH,wBAAsB,mBAAmB,CACxC,OAAO,GAAE,0BAA+B,GACtC,OAAO,CAAC,yBAAyB,CAAC,CAkDpC","sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { Api, Model, ThinkingLevelMap } from \"@ashx-j/lunr-ai\";\nimport { getAgentDir, getPackageDir, VERSION } from \"../config.ts\";\nimport { getPiUserAgent } from \"../utils/pi-user-agent.ts\";\n\n/** Directory on GitHub raw (`providers.json` + `providers/{id}.json`). Override with `LUNR_OFFICIAL_CATALOG_URL`. */\nexport const OFFICIAL_CATALOG_DEFAULT_URL = \"https://raw.githubusercontent.com/ashx-j/lunR/master/catalog\";\nexport const OFFICIAL_CATALOG_TIMEOUT_MS = 4000;\nexport const OFFICIAL_CATALOG_CACHE_FILENAME = \"official-catalog-cache.json\";\n\nconst THINKING_LEVEL_KEYS = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const;\nconst META_KEYS = new Set([\"version\", \"updatedAt\", \"generatedAt\", \"sourceCommit\", \"providerCount\", \"modelCount\"]);\n\nexport interface OfficialModelCost {\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n}\n\nexport interface OfficialModelEntry {\n\tid: string;\n\tname: string;\n\tapi: Api;\n\tprovider: string;\n\tbaseUrl: string;\n\treasoning: boolean;\n\tinput: (\"text\" | \"image\")[];\n\tcost: OfficialModelCost;\n\tcontextWindow: number;\n\tmaxTokens: number;\n\tcompat?: Model<Api>[\"compat\"];\n\tthinkingLevelMap?: ThinkingLevelMap;\n\theaders?: Record<string, string>;\n}\n\nexport interface OfficialCatalogFile {\n\tversion: number;\n\tupdatedAt: string;\n\tmodels: OfficialModelEntry[];\n}\n\nexport type OfficialCatalogSource = \"github\" | \"cache\" | \"bundled\";\n\nexport interface OfficialCatalogLoadResult {\n\tcatalog: OfficialCatalogFile;\n\tsource: OfficialCatalogSource;\n}\n\n/** Seed shipped in-repo; used when the JSON file cannot be read. */\nexport const BUNDLED_OFFICIAL_CATALOG: OfficialCatalogFile = {\n\tversion: 1,\n\tupdatedAt: \"2026-08-15T00:00:00Z\",\n\tmodels: [\n\t\t{\n\t\t\tid: \"grok-4.6\",\n\t\t\tname: \"Grok 4.6\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tprovider: \"xai\",\n\t\t\tbaseUrl: \"https://api.x.ai/v1\",\n\t\t\treasoning: true,\n\t\t\tinput: [\"text\", \"image\"],\n\t\t\tcost: { input: 2, output: 6, cacheRead: 0.5, cacheWrite: 0 },\n\t\t\tcontextWindow: 500000,\n\t\t\tmaxTokens: 500000,\n\t\t},\n\t],\n};\n\nexport function officialCatalogCachePath(agentDir: string = getAgentDir()): string {\n\treturn join(agentDir, OFFICIAL_CATALOG_CACHE_FILENAME);\n}\n\n/** Base URL (no trailing slash). `LUNR_OFFICIAL_CATALOG_URL` overrides the directory, not a single file. */\nexport function officialCatalogBaseUrl(override?: string): string {\n\tconst raw = (override ?? process.env.LUNR_OFFICIAL_CATALOG_URL)?.trim() || OFFICIAL_CATALOG_DEFAULT_URL;\n\treturn raw.replace(/\\/+$/, \"\");\n}\n\n/** @deprecated Use officialCatalogBaseUrl. Kept as an alias for the directory base. */\nexport function officialCatalogUrl(): string {\n\treturn officialCatalogBaseUrl();\n}\n\nexport function officialCatalogUrlFor(path: string, base?: string): string {\n\tconst normalized = path.replace(/^\\/+/, \"\");\n\treturn `${officialCatalogBaseUrl(base)}/${normalized}`;\n}\n\nexport function modelKey(provider: string, id: string): string {\n\treturn `${provider}/${id}`;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction asFiniteNumber(value: unknown): number | undefined {\n\tif (typeof value === \"number\" && Number.isFinite(value)) return value;\n\tif (typeof value === \"string\" && value.trim()) {\n\t\tconst parsed = Number(value);\n\t\tif (Number.isFinite(parsed)) return parsed;\n\t}\n\treturn undefined;\n}\n\nfunction parseCost(value: unknown): OfficialModelCost | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst input = asFiniteNumber(value.input);\n\tconst output = asFiniteNumber(value.output);\n\tif (input === undefined || output === undefined) return undefined;\n\treturn {\n\t\tinput,\n\t\toutput,\n\t\tcacheRead: asFiniteNumber(value.cacheRead) ?? 0,\n\t\tcacheWrite: asFiniteNumber(value.cacheWrite) ?? 0,\n\t};\n}\n\nfunction parseInput(value: unknown): (\"text\" | \"image\")[] | undefined {\n\tif (!Array.isArray(value)) return undefined;\n\tconst input: (\"text\" | \"image\")[] = [];\n\tfor (const entry of value) {\n\t\tif (entry === \"text\" || entry === \"image\") input.push(entry);\n\t}\n\treturn input.length > 0 ? input : undefined;\n}\n\nfunction parseThinkingLevelMap(value: unknown): ThinkingLevelMap | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst map: ThinkingLevelMap = {};\n\tlet any = false;\n\tfor (const level of THINKING_LEVEL_KEYS) {\n\t\tconst mapped = value[level];\n\t\tif (mapped === null || typeof mapped === \"string\") {\n\t\t\tmap[level] = mapped;\n\t\t\tany = true;\n\t\t}\n\t}\n\treturn any ? map : undefined;\n}\n\nfunction parseHeaders(value: unknown): Record<string, string> | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst headers: Record<string, string> = {};\n\tfor (const [name, headerValue] of Object.entries(value)) {\n\t\tif (typeof headerValue === \"string\") headers[name] = headerValue;\n\t}\n\treturn Object.keys(headers).length > 0 ? headers : undefined;\n}\n\nfunction parseOfficialEntry(value: unknown): OfficialModelEntry | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst id = typeof value.id === \"string\" ? value.id.trim() : \"\";\n\tconst provider = typeof value.provider === \"string\" ? value.provider.trim() : \"\";\n\tif (!id || !provider) return undefined;\n\tconst api = typeof value.api === \"string\" && value.api.trim() ? value.api.trim() : \"openai-completions\";\n\tconst name = typeof value.name === \"string\" && value.name.trim() ? value.name.trim() : id;\n\tconst baseUrl = typeof value.baseUrl === \"string\" ? value.baseUrl.trim() : \"\";\n\tconst cost = parseCost(value.cost) ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };\n\tconst input = parseInput(value.input) ?? [\"text\"];\n\tconst compat = isRecord(value.compat) ? (value.compat as Model<Api>[\"compat\"]) : undefined;\n\tconst thinkingLevelMap = parseThinkingLevelMap(value.thinkingLevelMap);\n\tconst headers = parseHeaders(value.headers);\n\treturn {\n\t\tid,\n\t\tname,\n\t\tapi: api as Api,\n\t\tprovider,\n\t\tbaseUrl,\n\t\treasoning: value.reasoning === true,\n\t\tinput,\n\t\tcost,\n\t\tcontextWindow: asFiniteNumber(value.contextWindow) ?? 128000,\n\t\tmaxTokens: asFiniteNumber(value.maxTokens) ?? 8192,\n\t\t...(compat ? { compat } : {}),\n\t\t...(thinkingLevelMap ? { thinkingLevelMap } : {}),\n\t\t...(headers ? { headers } : {}),\n\t};\n}\n\nfunction catalogFile(models: OfficialModelEntry[], value?: Record<string, unknown>): OfficialCatalogFile {\n\tconst version = value ? (asFiniteNumber(value.version) ?? 1) : 1;\n\tconst updatedAt = value && typeof value.updatedAt === \"string\" && value.updatedAt.trim() ? value.updatedAt : \"\";\n\treturn { version, updatedAt, models };\n}\n\nfunction parseKeyedCatalog(value: Record<string, unknown>): OfficialCatalogFile | undefined {\n\tconst models: OfficialModelEntry[] = [];\n\tfor (const [key, entry] of Object.entries(value)) {\n\t\tif (META_KEYS.has(key) || !isRecord(entry)) continue;\n\t\tif (typeof entry.id === \"string\") {\n\t\t\tconst parsed = parseOfficialEntry(entry);\n\t\t\tif (parsed) models.push(parsed);\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const [modelId, model] of Object.entries(entry)) {\n\t\t\tif (!isRecord(model)) continue;\n\t\t\tconst parsed = parseOfficialEntry({\n\t\t\t\t...model,\n\t\t\t\tid: typeof model.id === \"string\" && model.id.trim() ? model.id : modelId,\n\t\t\t\tprovider: typeof model.provider === \"string\" && model.provider.trim() ? model.provider : key,\n\t\t\t});\n\t\t\tif (parsed) models.push(parsed);\n\t\t}\n\t}\n\treturn models.length > 0 ? catalogFile(models, value) : undefined;\n}\n\n/** Parse an official catalog document. Returns undefined on a bad shape (never throws). */\nexport function parseOfficialCatalog(value: unknown): OfficialCatalogFile | undefined {\n\tif (!isRecord(value)) return undefined;\n\tif (Array.isArray(value.models)) {\n\t\tconst models: OfficialModelEntry[] = [];\n\t\tfor (const entry of value.models) {\n\t\t\tconst parsed = parseOfficialEntry(entry);\n\t\t\tif (parsed) models.push(parsed);\n\t\t}\n\t\treturn catalogFile(models, value);\n\t}\n\tif (\"models\" in value) return undefined;\n\treturn parseKeyedCatalog(value);\n}\n\nfunction parseProviderIndex(value: unknown): string[] | undefined {\n\tif (!Array.isArray(value) || !value.every((entry) => typeof entry === \"string\")) return undefined;\n\treturn value;\n}\n\nfunction readCatalogFile(path: string): OfficialCatalogFile | undefined {\n\ttry {\n\t\tif (!existsSync(path)) return undefined;\n\t\treturn parseOfficialCatalog(JSON.parse(readFileSync(path, \"utf-8\")));\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction bundledCatalogCandidates(): string[] {\n\tconst here = dirname(fileURLToPath(import.meta.url));\n\tconst packageDir = getPackageDir();\n\treturn [\n\t\tjoin(packageDir, \"dist\", \"catalog\", \"models.json\"),\n\t\tjoin(packageDir, \"..\", \"..\", \"catalog\", \"models.json\"),\n\t\tjoin(here, \"../../../../catalog/models.json\"),\n\t\tjoin(packageDir, \"catalog\", \"models.json\"),\n\t\tjoin(here, \"../catalog/models.json\"),\n\t\tjoin(here, \"models.json\"),\n\t\tjoin(packageDir, \"dist\", \"catalog\", \"official-models.json\"),\n\t\tjoin(packageDir, \"..\", \"..\", \"catalog\", \"official-models.json\"),\n\t\tjoin(here, \"../../../../catalog/official-models.json\"),\n\t\tjoin(here, \"official-models.json\"),\n\t\tjoin(here, \"../catalog/official-models.json\"),\n\t];\n}\n\nexport function loadBundledOfficialCatalog(): OfficialCatalogFile {\n\tfor (const path of bundledCatalogCandidates()) {\n\t\tconst parsed = readCatalogFile(path);\n\t\tif (parsed) return parsed;\n\t}\n\treturn BUNDLED_OFFICIAL_CATALOG;\n}\n\nexport function loadCachedOfficialCatalog(cachePath?: string): OfficialCatalogFile | undefined {\n\tif (!cachePath) return undefined;\n\treturn readCatalogFile(cachePath);\n}\n\nexport function writeOfficialCatalogCache(catalog: OfficialCatalogFile, cachePath: string): void {\n\ttry {\n\t\tmkdirSync(dirname(cachePath), { recursive: true, mode: 0o700 });\n\t\twriteFileSync(cachePath, `${JSON.stringify(catalog, null, 2)}\\n`, \"utf-8\");\n\t} catch {\n\t\t// Cache is best-effort.\n\t}\n}\n\nexport function officialModelsByProvider(catalog: OfficialCatalogFile): Map<string, OfficialModelEntry[]> {\n\tconst byProvider = new Map<string, OfficialModelEntry[]>();\n\tfor (const model of catalog.models) {\n\t\tconst list = byProvider.get(model.provider) ?? [];\n\t\tlist.push(model);\n\t\tbyProvider.set(model.provider, list);\n\t}\n\treturn byProvider;\n}\n\nexport function officialModelKeys(catalog: OfficialCatalogFile): Set<string> {\n\treturn new Set(catalog.models.map((model) => modelKey(model.provider, model.id)));\n}\n\nconst ZERO_COST = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };\n\nexport function officialEntryToModel(entry: OfficialModelEntry, template?: Model<Api>): Model<Api> {\n\treturn {\n\t\tid: entry.id,\n\t\tname: entry.name,\n\t\tapi: entry.api || template?.api || \"openai-completions\",\n\t\tprovider: entry.provider,\n\t\tbaseUrl: entry.baseUrl || template?.baseUrl || \"\",\n\t\treasoning: entry.reasoning,\n\t\tinput: entry.input.length > 0 ? entry.input : (template?.input ?? [\"text\"]),\n\t\tcost: entry.cost ?? template?.cost ?? ZERO_COST,\n\t\tcontextWindow: entry.contextWindow,\n\t\tmaxTokens: entry.maxTokens,\n\t\tcompat: entry.compat ?? template?.compat,\n\t\tthinkingLevelMap: entry.thinkingLevelMap ?? template?.thinkingLevelMap,\n\t\theaders: entry.headers ?? template?.headers,\n\t};\n}\n\nexport interface LoadOfficialCatalogOptions {\n\tallowNetwork?: boolean;\n\tcachePath?: string;\n\tbundled?: OfficialCatalogFile;\n\t/** Catalog directory base (not a single-file URL). */\n\turl?: string;\n\ttimeoutMs?: number;\n\tsignal?: AbortSignal;\n\tfetchImpl?: typeof fetch;\n\t/** Stored-credential provider ids. Only these shards are fetched. */\n\tproviderIds?: readonly string[];\n}\n\nfunction fallbackCatalog(bundled: OfficialCatalogFile, cachePath?: string): OfficialCatalogLoadResult {\n\tconst cached = loadCachedOfficialCatalog(cachePath);\n\tif (cached) return { catalog: cached, source: \"cache\" };\n\tif (bundled.models.length > 0) return { catalog: bundled, source: \"bundled\" };\n\treturn { catalog: BUNDLED_OFFICIAL_CATALOG, source: \"bundled\" };\n}\n\nasync function fetchJson(\n\turl: string,\n\toptions: {\n\t\ttimeoutMs: number;\n\t\tsignal?: AbortSignal;\n\t\tfetchImpl: typeof fetch;\n\t\theaders: Record<string, string>;\n\t},\n): Promise<{ ok: true; value: unknown } | { ok: false; status?: number }> {\n\tconst controller = new AbortController();\n\tconst timer = setTimeout(() => controller.abort(), options.timeoutMs);\n\tconst onParentAbort = () => controller.abort();\n\toptions.signal?.addEventListener(\"abort\", onParentAbort, { once: true });\n\tif (options.signal?.aborted) controller.abort();\n\ttry {\n\t\tconst abortError = () => {\n\t\t\tconst error = new Error(\"The operation was aborted\");\n\t\t\terror.name = \"AbortError\";\n\t\t\treturn error;\n\t\t};\n\t\tconst response = await Promise.race([\n\t\t\toptions.fetchImpl(url, {\n\t\t\t\theaders: options.headers,\n\t\t\t\tsignal: controller.signal,\n\t\t\t}),\n\t\t\tnew Promise<never>((_, reject) => {\n\t\t\t\tcontroller.signal.addEventListener(\"abort\", () => reject(abortError()), { once: true });\n\t\t\t\tif (controller.signal.aborted) reject(abortError());\n\t\t\t}),\n\t\t]);\n\t\tif (!response.ok) return { ok: false, status: response.status };\n\t\treturn { ok: true, value: await response.json() };\n\t} catch {\n\t\treturn { ok: false };\n\t} finally {\n\t\tclearTimeout(timer);\n\t\toptions.signal?.removeEventListener(\"abort\", onParentAbort);\n\t}\n}\n\n/**\n * Load the official overlay. Network only when allowNetwork is true.\n * Fetches providers.json, then providers/{id}.json for stored-credential providers.\n * 404 / timeout / any error falls back to cache, then bundled. Never throws.\n */\nexport async function loadOfficialCatalog(\n\toptions: LoadOfficialCatalogOptions = {},\n): Promise<OfficialCatalogLoadResult> {\n\tconst bundled = options.bundled ?? loadBundledOfficialCatalog();\n\tconst cachePath = options.cachePath;\n\tif (!options.allowNetwork) {\n\t\treturn fallbackCatalog(bundled, cachePath);\n\t}\n\n\tconst timeoutMs = options.timeoutMs ?? OFFICIAL_CATALOG_TIMEOUT_MS;\n\tconst fetchImpl = options.fetchImpl ?? fetch;\n\tconst headers = {\n\t\taccept: \"application/json\",\n\t\t\"User-Agent\": getPiUserAgent(VERSION),\n\t};\n\tconst fetchOptions = { timeoutMs, signal: options.signal, fetchImpl, headers };\n\tconst base = options.url ?? officialCatalogBaseUrl();\n\n\ttry {\n\t\tconst indexResult = await fetchJson(officialCatalogUrlFor(\"providers.json\", base), fetchOptions);\n\t\tif (!indexResult.ok) return fallbackCatalog(bundled, cachePath);\n\t\tconst index = parseProviderIndex(indexResult.value);\n\t\tif (!index) return fallbackCatalog(bundled, cachePath);\n\n\t\tconst wanted = new Set(index);\n\t\tconst requested = options.providerIds ?? [];\n\t\tconst shardIds = requested.filter((providerId) => wanted.has(providerId));\n\t\tif (shardIds.length === 0) return fallbackCatalog(bundled, cachePath);\n\n\t\tconst shards = await Promise.all(\n\t\t\tshardIds.map(async (providerId) => {\n\t\t\t\tconst result = await fetchJson(\n\t\t\t\t\tofficialCatalogUrlFor(`providers/${encodeURIComponent(providerId)}.json`, base),\n\t\t\t\t\tfetchOptions,\n\t\t\t\t);\n\t\t\t\tif (!result.ok) return [];\n\t\t\t\treturn parseOfficialCatalog(result.value)?.models ?? [];\n\t\t\t}),\n\t\t);\n\t\tconst models = shards.flat();\n\t\tif (models.length === 0) return fallbackCatalog(bundled, cachePath);\n\n\t\tconst catalog: OfficialCatalogFile = {\n\t\t\tversion: 1,\n\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\tmodels,\n\t\t};\n\t\tif (cachePath) writeOfficialCatalogCache(catalog, cachePath);\n\t\treturn { catalog, source: \"github\" };\n\t} catch {\n\t\treturn fallbackCatalog(bundled, cachePath);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"official-catalog.d.ts","sourceRoot":"","sources":["../../src/core/official-catalog.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAI1E,qHAAqH;AACrH,eAAO,MAAM,4BAA4B,iEAAiE,CAAC;AAC3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ID,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,kBAAkB,EAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAgBjG;AAED,MAAM,WAAW,0BAA0B;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,sDAAsD;IACtD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,qEAAqE;IACrE,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAChC;AAiDD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACxC,OAAO,GAAE,0BAA+B,GACtC,OAAO,CAAC,yBAAyB,CAAC,CAgDpC","sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { Api, Model, ThinkingLevelMap } from \"@ashx-j/lunr-ai\";\nimport { getAgentDir, getPackageDir, VERSION } from \"../config.ts\";\nimport { getPiUserAgent } from \"../utils/pi-user-agent.ts\";\n\n/** Directory on GitHub raw (`providers.json` + `providers/{id}.json`). Override with `LUNR_OFFICIAL_CATALOG_URL`. */\nexport const OFFICIAL_CATALOG_DEFAULT_URL = \"https://raw.githubusercontent.com/ashx-j/lunR/master/catalog\";\nexport const OFFICIAL_CATALOG_TIMEOUT_MS = 4000;\nexport const OFFICIAL_CATALOG_CACHE_FILENAME = \"official-catalog-cache.json\";\n\nconst THINKING_LEVEL_KEYS = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const;\nconst META_KEYS = new Set([\"version\", \"updatedAt\", \"generatedAt\", \"sourceCommit\", \"providerCount\", \"modelCount\"]);\n\nexport interface OfficialModelCost {\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n}\n\nexport interface OfficialModelEntry {\n\tid: string;\n\tname: string;\n\tapi: Api;\n\tprovider: string;\n\tbaseUrl: string;\n\treasoning: boolean;\n\tinput: (\"text\" | \"image\")[];\n\tcost: OfficialModelCost;\n\tcontextWindow: number;\n\tmaxTokens: number;\n\tcompat?: Model<Api>[\"compat\"];\n\tthinkingLevelMap?: ThinkingLevelMap;\n\theaders?: Record<string, string>;\n}\n\nexport interface OfficialCatalogFile {\n\tversion: number;\n\tupdatedAt: string;\n\tmodels: OfficialModelEntry[];\n}\n\nexport type OfficialCatalogSource = \"github\" | \"cache\" | \"bundled\";\n\nexport interface OfficialCatalogLoadResult {\n\tcatalog: OfficialCatalogFile;\n\tsource: OfficialCatalogSource;\n}\n\n/** Seed shipped in-repo; used when the JSON file cannot be read. */\nexport const BUNDLED_OFFICIAL_CATALOG: OfficialCatalogFile = {\n\tversion: 1,\n\tupdatedAt: \"2026-08-15T00:00:00Z\",\n\tmodels: [\n\t\t{\n\t\t\tid: \"grok-4.6\",\n\t\t\tname: \"Grok 4.6\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tprovider: \"xai\",\n\t\t\tbaseUrl: \"https://api.x.ai/v1\",\n\t\t\treasoning: true,\n\t\t\tinput: [\"text\", \"image\"],\n\t\t\tcost: { input: 2, output: 6, cacheRead: 0.5, cacheWrite: 0 },\n\t\t\tcontextWindow: 500000,\n\t\t\tmaxTokens: 500000,\n\t\t},\n\t],\n};\n\nexport function officialCatalogCachePath(agentDir: string = getAgentDir()): string {\n\treturn join(agentDir, OFFICIAL_CATALOG_CACHE_FILENAME);\n}\n\n/** Base URL (no trailing slash). `LUNR_OFFICIAL_CATALOG_URL` overrides the directory, not a single file. */\nexport function officialCatalogBaseUrl(override?: string): string {\n\tconst raw = (override ?? process.env.LUNR_OFFICIAL_CATALOG_URL)?.trim() || OFFICIAL_CATALOG_DEFAULT_URL;\n\treturn raw.replace(/\\/+$/, \"\");\n}\n\n/** @deprecated Use officialCatalogBaseUrl. Kept as an alias for the directory base. */\nexport function officialCatalogUrl(): string {\n\treturn officialCatalogBaseUrl();\n}\n\nexport function officialCatalogUrlFor(path: string, base?: string): string {\n\tconst normalized = path.replace(/^\\/+/, \"\");\n\treturn `${officialCatalogBaseUrl(base)}/${normalized}`;\n}\n\nexport function modelKey(provider: string, id: string): string {\n\treturn `${provider}/${id}`;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction asFiniteNumber(value: unknown): number | undefined {\n\tif (typeof value === \"number\" && Number.isFinite(value)) return value;\n\tif (typeof value === \"string\" && value.trim()) {\n\t\tconst parsed = Number(value);\n\t\tif (Number.isFinite(parsed)) return parsed;\n\t}\n\treturn undefined;\n}\n\nfunction parseCost(value: unknown): OfficialModelCost | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst input = asFiniteNumber(value.input);\n\tconst output = asFiniteNumber(value.output);\n\tif (input === undefined || output === undefined) return undefined;\n\treturn {\n\t\tinput,\n\t\toutput,\n\t\tcacheRead: asFiniteNumber(value.cacheRead) ?? 0,\n\t\tcacheWrite: asFiniteNumber(value.cacheWrite) ?? 0,\n\t};\n}\n\nfunction parseInput(value: unknown): (\"text\" | \"image\")[] | undefined {\n\tif (!Array.isArray(value)) return undefined;\n\tconst input: (\"text\" | \"image\")[] = [];\n\tfor (const entry of value) {\n\t\tif (entry === \"text\" || entry === \"image\") input.push(entry);\n\t}\n\treturn input.length > 0 ? input : undefined;\n}\n\nfunction parseThinkingLevelMap(value: unknown): ThinkingLevelMap | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst map: ThinkingLevelMap = {};\n\tlet any = false;\n\tfor (const level of THINKING_LEVEL_KEYS) {\n\t\tconst mapped = value[level];\n\t\tif (mapped === null || typeof mapped === \"string\") {\n\t\t\tmap[level] = mapped;\n\t\t\tany = true;\n\t\t}\n\t}\n\treturn any ? map : undefined;\n}\n\nfunction parseHeaders(value: unknown): Record<string, string> | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst headers: Record<string, string> = {};\n\tfor (const [name, headerValue] of Object.entries(value)) {\n\t\tif (typeof headerValue === \"string\") headers[name] = headerValue;\n\t}\n\treturn Object.keys(headers).length > 0 ? headers : undefined;\n}\n\nfunction parseOfficialEntry(value: unknown): OfficialModelEntry | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst id = typeof value.id === \"string\" ? value.id.trim() : \"\";\n\tconst provider = typeof value.provider === \"string\" ? value.provider.trim() : \"\";\n\tif (!id || !provider) return undefined;\n\tconst api = typeof value.api === \"string\" && value.api.trim() ? value.api.trim() : \"openai-completions\";\n\tconst name = typeof value.name === \"string\" && value.name.trim() ? value.name.trim() : id;\n\tconst baseUrl = typeof value.baseUrl === \"string\" ? value.baseUrl.trim() : \"\";\n\tconst cost = parseCost(value.cost) ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };\n\tconst input = parseInput(value.input) ?? [\"text\"];\n\tconst compat = isRecord(value.compat) ? (value.compat as Model<Api>[\"compat\"]) : undefined;\n\tconst thinkingLevelMap = parseThinkingLevelMap(value.thinkingLevelMap);\n\tconst headers = parseHeaders(value.headers);\n\treturn {\n\t\tid,\n\t\tname,\n\t\tapi: api as Api,\n\t\tprovider,\n\t\tbaseUrl,\n\t\treasoning: value.reasoning === true,\n\t\tinput,\n\t\tcost,\n\t\tcontextWindow: asFiniteNumber(value.contextWindow) ?? 128000,\n\t\tmaxTokens: asFiniteNumber(value.maxTokens) ?? 8192,\n\t\t...(compat ? { compat } : {}),\n\t\t...(thinkingLevelMap ? { thinkingLevelMap } : {}),\n\t\t...(headers ? { headers } : {}),\n\t};\n}\n\nfunction catalogFile(models: OfficialModelEntry[], value?: Record<string, unknown>): OfficialCatalogFile {\n\tconst version = value ? (asFiniteNumber(value.version) ?? 1) : 1;\n\tconst updatedAt = value && typeof value.updatedAt === \"string\" && value.updatedAt.trim() ? value.updatedAt : \"\";\n\treturn { version, updatedAt, models };\n}\n\nfunction parseKeyedCatalog(value: Record<string, unknown>): OfficialCatalogFile | undefined {\n\tconst models: OfficialModelEntry[] = [];\n\tfor (const [key, entry] of Object.entries(value)) {\n\t\tif (META_KEYS.has(key) || !isRecord(entry)) continue;\n\t\tif (typeof entry.id === \"string\") {\n\t\t\tconst parsed = parseOfficialEntry(entry);\n\t\t\tif (parsed) models.push(parsed);\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const [modelId, model] of Object.entries(entry)) {\n\t\t\tif (!isRecord(model)) continue;\n\t\t\tconst parsed = parseOfficialEntry({\n\t\t\t\t...model,\n\t\t\t\tid: typeof model.id === \"string\" && model.id.trim() ? model.id : modelId,\n\t\t\t\tprovider: typeof model.provider === \"string\" && model.provider.trim() ? model.provider : key,\n\t\t\t});\n\t\t\tif (parsed) models.push(parsed);\n\t\t}\n\t}\n\treturn models.length > 0 ? catalogFile(models, value) : undefined;\n}\n\n/** Parse an official catalog document. Returns undefined on a bad shape (never throws). */\nexport function parseOfficialCatalog(value: unknown): OfficialCatalogFile | undefined {\n\tif (!isRecord(value)) return undefined;\n\tif (Array.isArray(value.models)) {\n\t\tconst models: OfficialModelEntry[] = [];\n\t\tfor (const entry of value.models) {\n\t\t\tconst parsed = parseOfficialEntry(entry);\n\t\t\tif (parsed) models.push(parsed);\n\t\t}\n\t\treturn catalogFile(models, value);\n\t}\n\tif (\"models\" in value) return undefined;\n\treturn parseKeyedCatalog(value);\n}\n\nfunction parseProviderIndex(value: unknown): string[] | undefined {\n\tif (!Array.isArray(value) || !value.every((entry) => typeof entry === \"string\")) return undefined;\n\treturn value;\n}\n\nfunction readCatalogFile(path: string): OfficialCatalogFile | undefined {\n\ttry {\n\t\tif (!existsSync(path)) return undefined;\n\t\treturn parseOfficialCatalog(JSON.parse(readFileSync(path, \"utf-8\")));\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction bundledCatalogCandidates(): string[] {\n\tconst here = dirname(fileURLToPath(import.meta.url));\n\tconst packageDir = getPackageDir();\n\treturn [\n\t\tjoin(packageDir, \"dist\", \"catalog\", \"models.json\"),\n\t\tjoin(packageDir, \"..\", \"..\", \"catalog\", \"models.json\"),\n\t\tjoin(here, \"../../../../catalog/models.json\"),\n\t\tjoin(packageDir, \"catalog\", \"models.json\"),\n\t\tjoin(here, \"../catalog/models.json\"),\n\t\tjoin(here, \"models.json\"),\n\t\tjoin(packageDir, \"dist\", \"catalog\", \"official-models.json\"),\n\t\tjoin(packageDir, \"..\", \"..\", \"catalog\", \"official-models.json\"),\n\t\tjoin(here, \"../../../../catalog/official-models.json\"),\n\t\tjoin(here, \"official-models.json\"),\n\t\tjoin(here, \"../catalog/official-models.json\"),\n\t];\n}\n\nexport function loadBundledOfficialCatalog(): OfficialCatalogFile {\n\tfor (const path of bundledCatalogCandidates()) {\n\t\tconst parsed = readCatalogFile(path);\n\t\tif (parsed) return parsed;\n\t}\n\treturn BUNDLED_OFFICIAL_CATALOG;\n}\n\nexport function loadCachedOfficialCatalog(cachePath?: string): OfficialCatalogFile | undefined {\n\tif (!cachePath) return undefined;\n\treturn readCatalogFile(cachePath);\n}\n\nexport function writeOfficialCatalogCache(catalog: OfficialCatalogFile, cachePath: string): void {\n\ttry {\n\t\tmkdirSync(dirname(cachePath), { recursive: true, mode: 0o700 });\n\t\twriteFileSync(cachePath, `${JSON.stringify(catalog, null, 2)}\\n`, \"utf-8\");\n\t} catch {\n\t\t// Cache is best-effort.\n\t}\n}\n\nexport function officialModelsByProvider(catalog: OfficialCatalogFile): Map<string, OfficialModelEntry[]> {\n\tconst byProvider = new Map<string, OfficialModelEntry[]>();\n\tfor (const model of catalog.models) {\n\t\tconst list = byProvider.get(model.provider) ?? [];\n\t\tlist.push(model);\n\t\tbyProvider.set(model.provider, list);\n\t}\n\treturn byProvider;\n}\n\n/** Replace or add per-provider rows. Existing providers not in `replacements` are kept. */\nexport function mergeOfficialCatalogByProvider(\n\tbase: OfficialCatalogFile,\n\treplacements: ReadonlyMap<string, OfficialModelEntry[]>,\n\tupdatedAt?: string,\n): OfficialCatalogFile {\n\tconst byProvider = officialModelsByProvider(base);\n\tfor (const [providerId, models] of replacements) {\n\t\tbyProvider.set(providerId, models);\n\t}\n\treturn {\n\t\tversion: base.version || 1,\n\t\tupdatedAt: updatedAt ?? new Date().toISOString(),\n\t\tmodels: [...byProvider.values()].flat(),\n\t};\n}\n\n/** Bundled as the floor; cache rows win per provider. */\nexport function officialCatalogBase(bundled: OfficialCatalogFile, cachePath?: string): OfficialCatalogFile {\n\tconst cached = loadCachedOfficialCatalog(cachePath);\n\tif (!cached) return bundled;\n\treturn mergeOfficialCatalogByProvider(bundled, officialModelsByProvider(cached), cached.updatedAt);\n}\n\n/** A completed GitHub overlay must not be replaced by cache/bundled. */\nexport function preferOfficialCatalog(\n\tprevious: OfficialCatalogLoadResult | undefined,\n\tnext: OfficialCatalogLoadResult,\n): OfficialCatalogLoadResult {\n\tif (next.source === \"github\") return next;\n\tif (previous?.source === \"github\") return previous;\n\treturn next;\n}\n\nexport function officialModelKeys(catalog: OfficialCatalogFile): Set<string> {\n\treturn new Set(catalog.models.map((model) => modelKey(model.provider, model.id)));\n}\n\nconst ZERO_COST = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };\n\nexport function officialEntryToModel(entry: OfficialModelEntry, template?: Model<Api>): Model<Api> {\n\treturn {\n\t\tid: entry.id,\n\t\tname: entry.name,\n\t\tapi: entry.api || template?.api || \"openai-completions\",\n\t\tprovider: entry.provider,\n\t\tbaseUrl: entry.baseUrl || template?.baseUrl || \"\",\n\t\treasoning: entry.reasoning,\n\t\tinput: entry.input.length > 0 ? entry.input : (template?.input ?? [\"text\"]),\n\t\tcost: entry.cost ?? template?.cost ?? ZERO_COST,\n\t\tcontextWindow: entry.contextWindow,\n\t\tmaxTokens: entry.maxTokens,\n\t\tcompat: entry.compat ?? template?.compat,\n\t\tthinkingLevelMap: entry.thinkingLevelMap ?? template?.thinkingLevelMap,\n\t\theaders: entry.headers ?? template?.headers,\n\t};\n}\n\nexport interface LoadOfficialCatalogOptions {\n\tallowNetwork?: boolean;\n\tcachePath?: string;\n\tbundled?: OfficialCatalogFile;\n\t/** Catalog directory base (not a single-file URL). */\n\turl?: string;\n\ttimeoutMs?: number;\n\tsignal?: AbortSignal;\n\tfetchImpl?: typeof fetch;\n\t/** Stored-credential provider ids. Only these shards are fetched. */\n\tproviderIds?: readonly string[];\n}\n\nfunction fallbackCatalog(bundled: OfficialCatalogFile, cachePath?: string): OfficialCatalogLoadResult {\n\tconst cached = loadCachedOfficialCatalog(cachePath);\n\tif (cached) return { catalog: cached, source: \"cache\" };\n\tif (bundled.models.length > 0) return { catalog: bundled, source: \"bundled\" };\n\treturn { catalog: BUNDLED_OFFICIAL_CATALOG, source: \"bundled\" };\n}\n\nasync function fetchJson(\n\turl: string,\n\toptions: {\n\t\ttimeoutMs: number;\n\t\tsignal?: AbortSignal;\n\t\tfetchImpl: typeof fetch;\n\t\theaders: Record<string, string>;\n\t},\n): Promise<{ ok: true; value: unknown } | { ok: false; status?: number }> {\n\tconst controller = new AbortController();\n\tconst timer = setTimeout(() => controller.abort(), options.timeoutMs);\n\tconst onParentAbort = () => controller.abort();\n\toptions.signal?.addEventListener(\"abort\", onParentAbort, { once: true });\n\tif (options.signal?.aborted) controller.abort();\n\ttry {\n\t\tconst abortError = () => {\n\t\t\tconst error = new Error(\"The operation was aborted\");\n\t\t\terror.name = \"AbortError\";\n\t\t\treturn error;\n\t\t};\n\t\tconst response = await Promise.race([\n\t\t\toptions.fetchImpl(url, {\n\t\t\t\theaders: options.headers,\n\t\t\t\tsignal: controller.signal,\n\t\t\t}),\n\t\t\tnew Promise<never>((_, reject) => {\n\t\t\t\tcontroller.signal.addEventListener(\"abort\", () => reject(abortError()), { once: true });\n\t\t\t\tif (controller.signal.aborted) reject(abortError());\n\t\t\t}),\n\t\t]);\n\t\tif (!response.ok) return { ok: false, status: response.status };\n\t\treturn { ok: true, value: await response.json() };\n\t} catch {\n\t\treturn { ok: false };\n\t} finally {\n\t\tclearTimeout(timer);\n\t\toptions.signal?.removeEventListener(\"abort\", onParentAbort);\n\t}\n}\n\n/**\n * Load the official overlay. Network only when allowNetwork is true.\n * Fetches providers.json, then providers/{id}.json for stored-credential providers.\n * Successful shards replace that provider only; failed shards keep cache/bundled rows.\n * All requested shards failed → cache, then bundled. Never writes a worse cache. Never throws.\n */\nexport async function loadOfficialCatalog(\n\toptions: LoadOfficialCatalogOptions = {},\n): Promise<OfficialCatalogLoadResult> {\n\tconst bundled = options.bundled ?? loadBundledOfficialCatalog();\n\tconst cachePath = options.cachePath;\n\tif (!options.allowNetwork) {\n\t\treturn fallbackCatalog(bundled, cachePath);\n\t}\n\n\tconst timeoutMs = options.timeoutMs ?? OFFICIAL_CATALOG_TIMEOUT_MS;\n\tconst fetchImpl = options.fetchImpl ?? fetch;\n\tconst headers = {\n\t\taccept: \"application/json\",\n\t\t\"User-Agent\": getPiUserAgent(VERSION),\n\t};\n\tconst fetchOptions = { timeoutMs, signal: options.signal, fetchImpl, headers };\n\tconst base = options.url ?? officialCatalogBaseUrl();\n\n\ttry {\n\t\tconst indexResult = await fetchJson(officialCatalogUrlFor(\"providers.json\", base), fetchOptions);\n\t\tif (!indexResult.ok) return fallbackCatalog(bundled, cachePath);\n\t\tconst index = parseProviderIndex(indexResult.value);\n\t\tif (!index) return fallbackCatalog(bundled, cachePath);\n\n\t\tconst wanted = new Set(index);\n\t\tconst requested = options.providerIds ?? [];\n\t\tconst shardIds = requested.filter((providerId) => wanted.has(providerId));\n\t\tif (shardIds.length === 0) return fallbackCatalog(bundled, cachePath);\n\n\t\tconst replacements = new Map<string, OfficialModelEntry[]>();\n\t\tawait Promise.all(\n\t\t\tshardIds.map(async (providerId) => {\n\t\t\t\tconst result = await fetchJson(\n\t\t\t\t\tofficialCatalogUrlFor(`providers/${encodeURIComponent(providerId)}.json`, base),\n\t\t\t\t\tfetchOptions,\n\t\t\t\t);\n\t\t\t\tif (!result.ok) return;\n\t\t\t\tconst parsed = parseOfficialCatalog(result.value);\n\t\t\t\tif (!parsed || parsed.models.length === 0) return;\n\t\t\t\treplacements.set(providerId, parsed.models);\n\t\t\t}),\n\t\t);\n\t\tif (replacements.size === 0) return fallbackCatalog(bundled, cachePath);\n\n\t\tconst catalog = mergeOfficialCatalogByProvider(officialCatalogBase(bundled, cachePath), replacements);\n\t\tif (cachePath) writeOfficialCatalogCache(catalog, cachePath);\n\t\treturn { catalog, source: \"github\" };\n\t} catch {\n\t\treturn fallbackCatalog(bundled, cachePath);\n\t}\n}\n"]}
|
|
@@ -249,6 +249,33 @@ export function officialModelsByProvider(catalog) {
|
|
|
249
249
|
}
|
|
250
250
|
return byProvider;
|
|
251
251
|
}
|
|
252
|
+
/** Replace or add per-provider rows. Existing providers not in `replacements` are kept. */
|
|
253
|
+
export function mergeOfficialCatalogByProvider(base, replacements, updatedAt) {
|
|
254
|
+
const byProvider = officialModelsByProvider(base);
|
|
255
|
+
for (const [providerId, models] of replacements) {
|
|
256
|
+
byProvider.set(providerId, models);
|
|
257
|
+
}
|
|
258
|
+
return {
|
|
259
|
+
version: base.version || 1,
|
|
260
|
+
updatedAt: updatedAt ?? new Date().toISOString(),
|
|
261
|
+
models: [...byProvider.values()].flat(),
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/** Bundled as the floor; cache rows win per provider. */
|
|
265
|
+
export function officialCatalogBase(bundled, cachePath) {
|
|
266
|
+
const cached = loadCachedOfficialCatalog(cachePath);
|
|
267
|
+
if (!cached)
|
|
268
|
+
return bundled;
|
|
269
|
+
return mergeOfficialCatalogByProvider(bundled, officialModelsByProvider(cached), cached.updatedAt);
|
|
270
|
+
}
|
|
271
|
+
/** A completed GitHub overlay must not be replaced by cache/bundled. */
|
|
272
|
+
export function preferOfficialCatalog(previous, next) {
|
|
273
|
+
if (next.source === "github")
|
|
274
|
+
return next;
|
|
275
|
+
if (previous?.source === "github")
|
|
276
|
+
return previous;
|
|
277
|
+
return next;
|
|
278
|
+
}
|
|
252
279
|
export function officialModelKeys(catalog) {
|
|
253
280
|
return new Set(catalog.models.map((model) => modelKey(model.provider, model.id)));
|
|
254
281
|
}
|
|
@@ -317,7 +344,8 @@ async function fetchJson(url, options) {
|
|
|
317
344
|
/**
|
|
318
345
|
* Load the official overlay. Network only when allowNetwork is true.
|
|
319
346
|
* Fetches providers.json, then providers/{id}.json for stored-credential providers.
|
|
320
|
-
*
|
|
347
|
+
* Successful shards replace that provider only; failed shards keep cache/bundled rows.
|
|
348
|
+
* All requested shards failed → cache, then bundled. Never writes a worse cache. Never throws.
|
|
321
349
|
*/
|
|
322
350
|
export async function loadOfficialCatalog(options = {}) {
|
|
323
351
|
const bundled = options.bundled ?? loadBundledOfficialCatalog();
|
|
@@ -345,20 +373,19 @@ export async function loadOfficialCatalog(options = {}) {
|
|
|
345
373
|
const shardIds = requested.filter((providerId) => wanted.has(providerId));
|
|
346
374
|
if (shardIds.length === 0)
|
|
347
375
|
return fallbackCatalog(bundled, cachePath);
|
|
348
|
-
const
|
|
376
|
+
const replacements = new Map();
|
|
377
|
+
await Promise.all(shardIds.map(async (providerId) => {
|
|
349
378
|
const result = await fetchJson(officialCatalogUrlFor(`providers/${encodeURIComponent(providerId)}.json`, base), fetchOptions);
|
|
350
379
|
if (!result.ok)
|
|
351
|
-
return
|
|
352
|
-
|
|
380
|
+
return;
|
|
381
|
+
const parsed = parseOfficialCatalog(result.value);
|
|
382
|
+
if (!parsed || parsed.models.length === 0)
|
|
383
|
+
return;
|
|
384
|
+
replacements.set(providerId, parsed.models);
|
|
353
385
|
}));
|
|
354
|
-
|
|
355
|
-
if (models.length === 0)
|
|
386
|
+
if (replacements.size === 0)
|
|
356
387
|
return fallbackCatalog(bundled, cachePath);
|
|
357
|
-
const catalog =
|
|
358
|
-
version: 1,
|
|
359
|
-
updatedAt: new Date().toISOString(),
|
|
360
|
-
models,
|
|
361
|
-
};
|
|
388
|
+
const catalog = mergeOfficialCatalogByProvider(officialCatalogBase(bundled, cachePath), replacements);
|
|
362
389
|
if (cachePath)
|
|
363
390
|
writeOfficialCatalogCache(catalog, cachePath);
|
|
364
391
|
return { catalog, source: "github" };
|