mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-17 03:12:19 +03:00
303b70f75b
The Microsoft Store variant forced HERMES_GUEST_ONBOARDING=1 into its bundle env, and commit/channel builds could bake it with --bundle-env. Nothing reads it now. - scripts/bundles/desktop_inputs.py: the Store bundle env is just the request's. - bundle_env.py / bundle-env.mjs: the key is no longer allowed for new builds. - channel-protocol.ts: the key moves to RETIRED_BUNDLE_ENV_KEYS, so preview manifests already published with it still decode (the HERMES_SKIP_INTRO precedent). - BUILDING.md example uses HERMES_PREVIEW_FULL_CONNECTORS. - Build tests use another allowed key as their sample; both validators reject the retired key and the decoder drops it. - msix-virtualization.test.mjs: every generated MSIX manifest (store, release, canary, channel) keeps filesystem and registry write virtualisation disabled, and the builder config declares unvirtualizedResources. The machine marker and the shared %LOCALAPPDATA%\hermes root depend on that.
80 lines
4.2 KiB
JavaScript
80 lines
4.2 KiB
JavaScript
// Hermes shares %LOCALAPPDATA% and HKCU state with the unpackaged CLI/gateway,
|
|
// so every MSIX the repo produces must opt out of write virtualisation and the
|
|
// builder must request the restricted capability that permits it.
|
|
import { execFileSync } from 'node:child_process'
|
|
import fs from 'node:fs'
|
|
import { createRequire } from 'node:module'
|
|
import os from 'node:os'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { afterEach, expect, test } from 'vitest'
|
|
import { stageChannelManifest } from '../../../scripts/msix-shared.mjs'
|
|
import { stageReleaseManifest, stageStoreManifest } from './before-build.mjs'
|
|
|
|
const require = createRequire(import.meta.url)
|
|
const desktop = fileURLToPath(new URL('../', import.meta.url))
|
|
const roots = []
|
|
afterEach(() => { for (const root of roots.splice(0)) fs.rmSync(root, { recursive: true, force: true }) })
|
|
|
|
function virtualization(xml) {
|
|
const read = name => new RegExp(`<desktop6:${name}>([^<]*)</desktop6:${name}>`).exec(xml)?.[1]
|
|
return { fileSystem: read('FileSystemWriteVirtualization'), registry: read('RegistryWriteVirtualization') }
|
|
}
|
|
|
|
// A tagged app dir: the real template plus just enough for appIdentity.
|
|
function taggedApp(tag) {
|
|
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'msix-virt-'))
|
|
roots.push(root)
|
|
const app = path.join(root, 'apps', 'desktop')
|
|
fs.mkdirSync(path.join(app, 'assets'), { recursive: true })
|
|
fs.copyFileSync(path.join(desktop, 'assets/msix-manifest.xml'), path.join(app, 'assets/msix-manifest.xml'))
|
|
fs.writeFileSync(path.join(app, 'product-identity.cjs'), "module.exports={store:true,artifactNamePascal:'HermesBundled'}\n")
|
|
fs.writeFileSync(path.join(app, 'package.json'), JSON.stringify({ name: 'hermes', version: '0.27.1' }))
|
|
const env = { ...process.env, GIT_AUTHOR_NAME: 'Test', GIT_AUTHOR_EMAIL: 'test@example.invalid',
|
|
GIT_COMMITTER_NAME: 'Test', GIT_COMMITTER_EMAIL: 'test@example.invalid',
|
|
GIT_AUTHOR_DATE: '2026-09-07T00:18:00Z', GIT_COMMITTER_DATE: '2026-09-07T00:18:00Z' }
|
|
for (const args of [['init', '-q'], ['add', '.'], ['-c', 'commit.gpgsign=false', 'commit', '-qm', 'fixture'], ['tag', tag]]) {
|
|
execFileSync('git', args, { cwd: root, env, stdio: 'pipe' })
|
|
}
|
|
return app
|
|
}
|
|
|
|
// A channel app dir: stageChannelManifest loads scripts/before-build.mjs from it,
|
|
// so link the real scripts directory (a junction needs no privilege on Windows).
|
|
function channelApp() {
|
|
const app = fs.mkdtempSync(path.join(os.tmpdir(), 'msix-virt-channel-'))
|
|
roots.push(app)
|
|
fs.mkdirSync(path.join(app, 'assets'))
|
|
fs.mkdirSync(path.join(app, 'build/agent-payload'), { recursive: true })
|
|
fs.copyFileSync(path.join(desktop, 'assets/msix-manifest.xml'), path.join(app, 'assets/msix-manifest.xml'))
|
|
fs.writeFileSync(path.join(app, 'build/agent-payload/manifest.json'), JSON.stringify({ launchers: ['hermes'] }))
|
|
fs.writeFileSync(path.join(app, 'build/msix-extensions.xml'), '<Extensions />')
|
|
fs.symlinkSync(path.join(desktop, 'scripts'), path.join(app, 'scripts'), 'junction')
|
|
return app
|
|
}
|
|
|
|
test('store, release, canary and channel MSIX manifests keep write virtualisation disabled', () => {
|
|
const store = taggedApp('v0.27.1')
|
|
const canary = taggedApp('v0.27.1+canary.20260907T001800Z')
|
|
fs.mkdirSync(path.join(canary, 'build'), { recursive: true })
|
|
fs.copyFileSync(path.join(canary, 'assets/msix-manifest.xml'), path.join(canary, 'build/msix-manifest.xml'))
|
|
const channel = channelApp()
|
|
stageChannelManifest(channel, {
|
|
windowsVersion: '0.0.7.0', identity: { appNamePascal: 'HermesChannelab12', displayName: 'Hermes preview' }
|
|
})
|
|
const manifests = {
|
|
store: stageStoreManifest(store, 'v0.27.1'),
|
|
release: stageReleaseManifest(taggedApp('v0.27.1'), 'v0.27.1'),
|
|
canary: stageReleaseManifest(canary, 'v0.27.1+canary.20260907T001800Z'),
|
|
channel: path.join(channel, 'build/msix-manifest.xml')
|
|
}
|
|
for (const [kind, file] of Object.entries(manifests)) {
|
|
expect([kind, virtualization(fs.readFileSync(file, 'utf8'))]).toEqual([kind, { fileSystem: 'disabled', registry: 'disabled' }])
|
|
}
|
|
})
|
|
|
|
test('the builder config requests unvirtualizedResources for MSIX packages', () => {
|
|
const config = require('../electron-builder.config.cjs')
|
|
expect(config.msix.capabilities).toContain('unvirtualizedResources')
|
|
})
|