Registers llm on the real MJGlobal.Instance.ClassFactory under one or more
DriverClass names — exactly how production drivers resolve. Every
ClassFactory.CreateInstance<BaseLLM>(BaseLLM, driverClass, apiKey) for a
registered name yields the SAME scripted instance, so a test scripts and
asserts through one object no matter how many drivers the code under test
instantiates.
Registrations persist on the MJGlobal singleton and the ClassFactory has no
unregister API. In unit tests, pair with resetMJSingletons() from this package in
beforeEach/afterEach so each test gets a fresh factory. In a long-lived process
that must keep its real providers (the integration suite runs every bundle in one
process), call the returned restore() in a finally instead: it re-registers, above
the TestLLM, whatever class each name resolved to before. A name that had no prior
registration has nothing to restore and keeps resolving to the TestLLM. The TestLLM is
registered at priority or above every registration the name already has, whichever is
higher, so it also wins over a class an earlier restore() put back.
Registers
llmon the realMJGlobal.Instance.ClassFactoryunder one or more DriverClass names — exactly how production drivers resolve. EveryClassFactory.CreateInstance<BaseLLM>(BaseLLM, driverClass, apiKey)for a registered name yields the SAME scripted instance, so a test scripts and asserts through one object no matter how many drivers the code under test instantiates.Registrations persist on the MJGlobal singleton and the ClassFactory has no unregister API. In unit tests, pair with
resetMJSingletons()from this package inbeforeEach/afterEachso each test gets a fresh factory. In a long-lived process that must keep its real providers (the integration suite runs every bundle in one process), call the returnedrestore()in afinallyinstead: it re-registers, above the TestLLM, whatever class each name resolved to before. A name that had no prior registration has nothing to restore and keeps resolving to the TestLLM. The TestLLM is registered atpriorityor above every registration the name already has, whichever is higher, so it also wins over a class an earlierrestore()put back.