fix(plugin-sdk): lazy acp runtime testing merge

This commit is contained in:
Vincent Koc 2026-04-04 14:43:39 +09:00
parent fd01561327
commit 32dd0aa7e7
1 changed files with 26 additions and 4 deletions

View File

@ -26,7 +26,29 @@ export type {
export { readAcpSessionEntry } from "../acp/runtime/session-meta.js";
export type { AcpSessionStoreEntry } from "../acp/runtime/session-meta.js";
export const __testing = {
...managerTesting,
...registryTesting,
};
// Keep test helpers off the hot init path. Eagerly merging them here can
// create a back-edge through the bundled ACP runtime chunk before the imported
// testing bindings finish initialization.
export const __testing = new Proxy({} as typeof managerTesting & typeof registryTesting, {
get(_target, prop, receiver) {
if (Reflect.has(managerTesting, prop)) {
return Reflect.get(managerTesting, prop, receiver);
}
return Reflect.get(registryTesting, prop, receiver);
},
has(_target, prop) {
return Reflect.has(managerTesting, prop) || Reflect.has(registryTesting, prop);
},
ownKeys() {
return Array.from(new Set([...Reflect.ownKeys(managerTesting), ...Reflect.ownKeys(registryTesting)]));
},
getOwnPropertyDescriptor(_target, prop) {
if (Reflect.has(managerTesting, prop) || Reflect.has(registryTesting, prop)) {
return {
configurable: true,
enumerable: true,
};
}
return undefined;
},
});