mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-18 14:52:04 +00:00
Ports the engine off the second JS runtime onto Node 26.3 (node:ffi) so the repo ships a single JavaScript runtime: child_process for the gateway, vitest for tests, an esbuild + Solid build step. Mouse selection copies the rendered text you highlight, and the clipboard path is crash-proofed (a broken copy pipe no longer quits the UI). Renames the engine dir ui-tui-opentui-v2/ -> ui-opentui/ and updates the launcher/installer/Docker references.
59 lines
2.2 KiB
TypeScript
59 lines
2.2 KiB
TypeScript
/**
|
|
* Vitest config for the Node-26 engine (replaces `bun test`).
|
|
*
|
|
* Same Solid transform as the production build (scripts/build.mjs): app .tsx/.jsx
|
|
* go through babel-preset-solid in `generate:"universal"` mode with
|
|
* `moduleName:"@opentui/solid"`, and solid-js resolves to its CLIENT build (the
|
|
* package `node` condition points at the SSR `server.js`, which lacks the
|
|
* universal reactive primitives). See docs/plans/opentui-node26-build-spec.md.
|
|
*
|
|
* render.test.tsx mounts the native @opentui/solid test renderer, so the test
|
|
* forks need `--experimental-ffi`. We inject it into NODE_OPTIONS here (the config
|
|
* runs in vitest's main process before it forks workers, which inherit the env) —
|
|
* self-contained and cross-platform, no shell wrapper needed. The other suites are
|
|
* pure logic.
|
|
*/
|
|
import { transformAsync } from '@babel/core'
|
|
import tsPreset from '@babel/preset-typescript'
|
|
import solidPreset from 'babel-preset-solid'
|
|
import { createRequire } from 'node:module'
|
|
import type { Plugin } from 'vite'
|
|
import { defineConfig } from 'vitest/config'
|
|
|
|
const require = createRequire(import.meta.url)
|
|
|
|
// Ensure forked test workers load OpenTUI's native core via node:ffi.
|
|
const ffiOpts = '--experimental-ffi --no-warnings'
|
|
if (!(process.env.NODE_OPTIONS ?? '').includes('--experimental-ffi')) {
|
|
process.env.NODE_OPTIONS = `${process.env.NODE_OPTIONS ?? ''} ${ffiOpts}`.trim()
|
|
}
|
|
|
|
const opentuiSolid = (): Plugin => ({
|
|
name: 'opentui-solid',
|
|
enforce: 'pre',
|
|
async transform(code, id) {
|
|
const path = id.split('?')[0]
|
|
if (!/\.[cm]?[jt]sx$/.test(path) || path.includes('/node_modules/')) return null
|
|
const out = await transformAsync(code, {
|
|
filename: path,
|
|
configFile: false,
|
|
babelrc: false,
|
|
sourceMaps: true,
|
|
presets: [[solidPreset, { moduleName: '@opentui/solid', generate: 'universal' }], [tsPreset]]
|
|
})
|
|
return out?.code ? { code: out.code, map: out.map } : null
|
|
}
|
|
})
|
|
|
|
export default defineConfig({
|
|
plugins: [opentuiSolid()],
|
|
resolve: {
|
|
alias: [
|
|
{ find: /^solid-js\/store$/, replacement: require.resolve('solid-js/store/dist/store.js') },
|
|
{ find: /^solid-js$/, replacement: require.resolve('solid-js/dist/solid.js') }
|
|
]
|
|
},
|
|
test: {
|
|
include: ['src/test/**/*.test.{ts,tsx}']
|
|
}
|
|
})
|