refactor: migrate to ModelRegistry.create factory

ModelRegistry's public constructor became private in pi-coding-agent 0.64.
Direct `new ModelRegistry(...)` calls no longer compile. Switch the five
production sites to the factory (`ModelRegistry.create`) and update the
four test modules that mocked the class as a constructor to now mock it
as an object with `create` and `inMemory` static methods.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-04-23 17:13:26 -07:00
parent d8a1158d40
commit 9cfd09c5d9
9 changed files with 27 additions and 14 deletions

View File

@@ -514,14 +514,14 @@ export class TaskExecutor {
private totalSpawnedCount = 0;
/** Token cap detector for proactive context compaction. */
private tokenCapDetector = new TokenCapDetector();
private _modelRegistry?: InstanceType<typeof ModelRegistry>;
private _modelRegistry?: ModelRegistry;
/** Current run context for mutation correlation. Set at execute() start, cleared in finally. */
private currentRunContext: RunMutationContext | undefined;
private get modelRegistry(): InstanceType<typeof ModelRegistry> {
private get modelRegistry(): ModelRegistry {
if (!this._modelRegistry) {
const authStorage = createFusionAuthStorage();
this._modelRegistry = new ModelRegistry(authStorage, getModelRegistryModelsPath());
this._modelRegistry = ModelRegistry.create(authStorage, getModelRegistryModelsPath());
this._modelRegistry.refresh();
}
return this._modelRegistry;

View File

@@ -674,7 +674,7 @@ export function wrapToolsWithBoundary(
export async function createFnAgent(options: AgentOptions): Promise<AgentResult> {
piLog.log(`createFnAgent called (cwd=${options.cwd}, tools=${options.tools}, provider=${options.defaultProvider}, model=${options.defaultModelId})`);
const authStorage = createFusionAuthStorage();
const modelRegistry = new ModelRegistry(authStorage, getModelRegistryModelsPath());
const modelRegistry = ModelRegistry.create(authStorage, getModelRegistryModelsPath());
await registerExtensionProviders(options.cwd, modelRegistry);
const tools =