Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
/** Generate source text for the isolated WebView. Hermes does not retain Function#toString source. */
import fs from 'node:fs';
import ts from 'typescript';
import { fileURLToPath } from 'node:url';
const source = fileURLToPath(new URL('../apps/mobile/src/plugins/pluginPageBootstrap.ts', import.meta.url));
const target = fileURLToPath(new URL('../apps/mobile/src/plugins/pluginPageBootstrap.generated.ts', import.meta.url));
const compiled = ts.transpileModule(fs.readFileSync(source, 'utf8'), {
compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.ESNext },
}).outputText.replace('export function bootstrap(', 'function bootstrap(').replace(/export \{\};?\s*$/, '');
const output = '// Generated by scripts/generate-mobile-plugin-bootstrap.mjs. Edit pluginPageBootstrap.ts.\n'
+ 'export const PLUGIN_PAGE_BOOTSTRAP = ' + JSON.stringify(compiled) + ';\n';
if (process.argv.includes('--check')) {
if (!fs.existsSync(target) || fs.readFileSync(target, 'utf8') !== output) {
process.stderr.write('Mobile plugin bootstrap is stale; run node scripts/generate-mobile-plugin-bootstrap.mjs\n');
process.exitCode = 1;
}
} else fs.writeFileSync(target, output);