const sources = __AGC_SOURCES__;
const version = __AGC_VERSION__;
const schema = __AGC_SCHEMA__;
const operationNames = __AGC_NAMES__;
const key = Symbol.for('agc.cocos.operations');
let instance = globalThis[key];
if (!instance || instance.version !== version) {
  if (instance) await instance.runtime.dispose();
  const cache = {};
  const load = (name) => {
    if (!Object.hasOwn(sources, name)) throw new Error('未登记的内置模块');
    if (!cache[name]) {
      const module = { exports: {} };
      new Function('module', 'exports', sources[name])(module, module.exports);
      cache[name] = module.exports;
    }
    return cache[name];
  };
  instance = { version, runtime: load('main.cjs')(Editor, require, load, sources, version, operationNames) };
  globalThis[key] = instance;
}
return await instance.runtime.execute(__AGC_OPERATION__, __AGC_ARGS__, schema);
