The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
chore: add explicit types to desktop identity tests
ethernet6b1672d3750a
diff --git a/apps/desktop/electron/cli-provision.test.ts b/apps/desktop/electron/cli-provision.test.tsindex c1eada80c37..cc7b06d92d3 100644--- a/apps/desktop/electron/cli-provision.test.ts+++ b/apps/desktop/electron/cli-provision.test.ts@@ -3,7 +3,7 @@ import fs from 'node:fs'import os from 'node:os'import path from 'node:path'-import { test } from 'vitest'+import { test, type TestContext } from 'vitest'import { provisionCliLinks } from './cli-provision'@@ -68,11 +68,11 @@ test('repairs owned dangling CLI links without changing foreign or live entries'}})-test('qualified CLI paths expose their filenames, not shared canonical command keys', context => {- const { root, binDir, source } = fixture()+test('qualified CLI paths expose their filenames, not shared canonical command keys', (context: TestContext): void => {+ const { root, binDir, source }: ReturnType<typeof fixture> = fixture()try {- const plain = path.join(binDir, 'hermes')+ const plain: string = path.join(binDir, 'hermes')fs.writeFileSync(plain, 'stable command')try {@@ -87,11 +87,11 @@ test('qualified CLI paths expose their filenames, not shared canonical command k}for (const name of ['hermes-canary', 'hermes-abcdef1', 'hermes-1234567']) {- const cli = path.join(path.dirname(source), name)- const acp = `${cli}-acp`+ const cli: string = path.join(path.dirname(source), name)+ const acp: string = `${cli}-acp`fs.writeFileSync(cli, name)fs.writeFileSync(acp, `${name}-acp`)- provisionCliLinks({ hermes: cli, 'hermes-acp': acp }, binDir, () => {})+ provisionCliLinks({ hermes: cli, 'hermes-acp': acp }, binDir, (): void => {})assert.equal(fs.readlinkSync(path.join(binDir, name)), cli)assert.equal(fs.readlinkSync(path.join(binDir, `${name}-acp`)), acp)}diff --git a/apps/desktop/electron/cli-provision.ts b/apps/desktop/electron/cli-provision.tsindex a47fd7eb31b..2749b5bfa4f 100644--- a/apps/desktop/electron/cli-provision.ts+++ b/apps/desktop/electron/cli-provision.ts@@ -22,7 +22,7 @@ export function provisionCliLinks(for (const source of Object.values(commands)) {// The map keys are backend entrypoint identities, not public shell names.- const name = path.basename(source)+ const name: string = path.basename(source)const target = path.join(binDir, name)try {diff --git a/apps/desktop/electron/product-identity.test.ts b/apps/desktop/electron/product-identity.test.tsindex 885ace2ce09..1876ea3bdc7 100644--- a/apps/desktop/electron/product-identity.test.ts+++ b/apps/desktop/electron/product-identity.test.ts@@ -11,16 +11,27 @@ import os from 'node:os'import path from 'node:path'import { fileURLToPath } from 'node:url'-import { build } from 'esbuild'+import type { AppInfo as BuilderAppInfo, Configuration, Metadata, Packager, Protocol } from 'app-builder-lib'+import { build, type BuildResult } from 'esbuild'import { afterEach, beforeEach, test, vi } from 'vitest'-const require = createRequire(import.meta.url)+import type { applyDesktopIdentity, ProductIdentity } from './product-identity'-beforeEach(() => {+type PackagingConfiguration = Omit<Configuration, 'extraMetadata' | 'mac' | 'msix' | 'protocols' | 'win'> & {+ extraMetadata: Metadata+ mac: Omit<NonNullable<Configuration['mac']>, 'extendInfo'> & { extendInfo: { CFBundleExecutable: string } }+ msix: NonNullable<Configuration['msix']>+ protocols: Protocol[]+ win: NonNullable<Configuration['win']>+}++const require: NodeJS.Require = createRequire(import.meta.url)++beforeEach((): void => {vi.resetModules()})-afterEach(() => {+afterEach((): void => {delete process.env.HERMES_DESKTOP_VARIANTdelete process.env.HERMES_PAYLOAD_TAGdelete process.env.HERMES_BUILD_COMMIT@@ -28,7 +39,7 @@ afterEach(() => {vi.resetModules()})-async function identityForVariant(variant: string | undefined) {+async function identityForVariant(variant: string | undefined): Promise<ProductIdentity> {if (variant === undefined) {delete process.env.HERMES_DESKTOP_VARIANT} else {@@ -41,24 +52,33 @@ async function identityForVariant(variant: string | undefined) {return (await import('./product-identity')).PRODUCT_IDENTITY}-test('baked runtime identity never evaluates ambient build selectors', async () => {- const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'baked-identity-'))+test('baked runtime identity never evaluates ambient build selectors', async (): Promise<void> => {+ const dir: string = fs.mkdtempSync(path.join(os.tmpdir(), 'baked-identity-'))try {- const identity = await identityForVariant('bundled')-- const result = await build({- stdin: { contents: "import {PRODUCT_IDENTITY} from './product-identity'; console.log(JSON.stringify(PRODUCT_IDENTITY))", resolveDir: import.meta.dirname },- bundle: true, platform: 'node', format: 'esm', write: false,+ const identity: ProductIdentity = await identityForVariant('bundled')++ const result: BuildResult<{ write: false }> = await build({+ stdin: {+ contents: "import {PRODUCT_IDENTITY} from './product-identity'; console.log(JSON.stringify(PRODUCT_IDENTITY))",+ resolveDir: import.meta.dirname+ },+ bundle: true,+ platform: 'node',+ format: 'esm',+ write: false,define: { __HERMES_PRODUCT_IDENTITY__: JSON.stringify(identity) }})- const file = path.join(dir, 'identity.mjs')+ const file: string = path.join(dir, 'identity.mjs')fs.writeFileSync(file, result.outputFiles[0].text)- const actual = JSON.parse(execFileSync(process.execPath, [file], {- encoding: 'utf8', env: { ...process.env, HERMES_DESKTOP_VARIANT: 'store', HERMES_BUILD_COMMIT: 'a'.repeat(40) }- }))+ const actual: unknown = JSON.parse(+ execFileSync(process.execPath, [file], {+ encoding: 'utf8',+ env: { ...process.env, HERMES_DESKTOP_VARIANT: 'store', HERMES_BUILD_COMMIT: 'a'.repeat(40) }+ })+ )assert.deepEqual(actual, identity)} finally {@@ -66,19 +86,24 @@ test('baked runtime identity never evaluates ambient build selectors', async ()}})-test('nonstable runtime pins userData before the app name can change', async () => {- const stable = await identityForVariant('bundled')+test('nonstable runtime pins userData before the app name can change', async (): Promise<void> => {+ const stable: ProductIdentity = await identityForVariant('bundled')process.env.HERMES_PAYLOAD_TAG = 'v0.28.0-canary.20260818'- const canary = await identityForVariant('bundled')- const runtime = await import('./product-identity')- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'identity-userdata-'))+ const canary: ProductIdentity = await identityForVariant('bundled')+ const runtime: { applyDesktopIdentity: typeof applyDesktopIdentity } = await import('./product-identity')+ const root: string = fs.mkdtempSync(path.join(os.tmpdir(), 'identity-userdata-'))const paths: Record<string, string> = { appData: root, userData: path.join(root, 'Hermes') }- let name = 'Hermes'-- const app = {- getPath: (key: string) => paths[key],- setPath: (key: string, value: string) => { assert.ok(fs.statSync(value).isDirectory()); paths[key] = value },- setName: (value: string) => { name = value }+ let name: string = 'Hermes'++ const app: Parameters<typeof applyDesktopIdentity>[0] = {+ getPath: (key: string): string => paths[key],+ setPath: (key: string, value: string): void => {+ assert.ok(fs.statSync(value).isDirectory())+ paths[key] = value+ },+ setName: (value: string): void => {+ name = value+ }}try {@@ -92,9 +117,9 @@ test('nonstable runtime pins userData before the app name can change', async ()}})-test('light identity is fully distinct from the full identity', async () => {- const full = await identityForVariant(undefined)- const light = await identityForVariant('light')+test('light identity is fully distinct from the full identity', async (): Promise<void> => {+ const full: ProductIdentity = await identityForVariant(undefined)+ const light: ProductIdentity = await identityForVariant('light')assert.equal(light.light, true)@@ -107,24 +132,31 @@ test('light identity is fully distinct from the full identity', async () => {}})-test('a canary payload tag moves BOTH variants onto their canary feed channel', async () => {+test('a canary payload tag moves BOTH variants onto their canary feed channel', async (): Promise<void> => {process.env.HERMES_PAYLOAD_TAG = 'v0.28.0-canary.20260818'- const full = await identityForVariant(undefined)+ const full: ProductIdentity = await identityForVariant(undefined)assert.equal(full.channel, 'canary')process.env.HERMES_PAYLOAD_TAG = 'v0.28.0-canary.20260818'- const light = await identityForVariant('light')+ const light: ProductIdentity = await identityForVariant('light')assert.equal(light.channel, 'light-canary')})-test('canary installs alongside stable with its own GUI and CLI names', async () => {+test('canary installs alongside stable with its own GUI and CLI names', async (): Promise<void> => {for (const variant of [undefined, 'bundled', 'light']) {delete process.env.HERMES_PAYLOAD_TAG- const stable = await identityForVariant(variant)+ const stable: ProductIdentity = await identityForVariant(variant)process.env.HERMES_PAYLOAD_TAG = 'v0.28.0-canary.20260818'- const canary = await identityForVariant(variant)-- for (const prop of ['displayName', 'appId', 'appNamePascal', 'msixAppIdWithOrg', 'windowsExecutableName', 'cliName'] as const) {+ const canary: ProductIdentity = await identityForVariant(variant)++ for (const prop of [+ 'displayName',+ 'appId',+ 'appNamePascal',+ 'msixAppIdWithOrg',+ 'windowsExecutableName',+ 'cliName'+ ] as const) {assert.notEqual(canary[prop], stable[prop], `${prop} must isolate canary`)}@@ -134,20 +166,27 @@ test('canary installs alongside stable with its own GUI and CLI names', async ()}})-test('each commit owns a deterministic identity and has no release channel', async () => {- const firstSha = 'abcdef1234567890abcdef1234567890abcdef12'- const secondSha = '1234567890abcdef1234567890abcdef12345678'+test('each commit owns a deterministic identity and has no release channel', async (): Promise<void> => {+ const firstSha: string = 'abcdef1234567890abcdef1234567890abcdef12'+ const secondSha: string = '1234567890abcdef1234567890abcdef12345678'for (const variant of [undefined, 'bundled', 'light']) {delete process.env.HERMES_BUILD_COMMIT- const stable = await identityForVariant(variant)+ const stable: ProductIdentity = await identityForVariant(variant)process.env.HERMES_BUILD_COMMIT = firstSha- const first = await identityForVariant(variant)+ const first: ProductIdentity = await identityForVariant(variant)assert.deepEqual(first, await identityForVariant(variant))process.env.HERMES_BUILD_COMMIT = secondSha- const second = await identityForVariant(variant)-- for (const prop of ['displayName', 'appId', 'appNamePascal', 'msixAppIdWithOrg', 'windowsExecutableName', 'cliName'] as const) {+ const second: ProductIdentity = await identityForVariant(variant)++ for (const prop of [+ 'displayName',+ 'appId',+ 'appNamePascal',+ 'msixAppIdWithOrg',+ 'windowsExecutableName',+ 'cliName'+ ] as const) {assert.notEqual(first[prop], stable[prop], `${prop} must isolate commit from stable`)assert.notEqual(first[prop], second[prop], `${prop} must isolate two commits`)assert.ok(first[prop].includes(firstSha.slice(0, 7)))@@ -159,59 +198,74 @@ test('each commit owns a deterministic identity and has no release channel', asy}})-test('a commit build names the SHA in the display name', async () => {+test('a commit build names the SHA in the display name', async (): Promise<void> => {process.env.HERMES_BUILD_COMMIT = 'abcdef1234567890abcdef1234567890abcdef12'- const full = await identityForVariant(undefined)+ const full: ProductIdentity = await identityForVariant(undefined)assert.equal(full.displayName, 'Hermes abcdef1')- const bundled = await identityForVariant('bundled')+ const bundled: ProductIdentity = await identityForVariant('bundled')assert.equal(bundled.displayName, 'Hermes Agent abcdef1')delete process.env.HERMES_BUILD_COMMIT- const plain = await identityForVariant(undefined)+ const plain: ProductIdentity = await identityForVariant(undefined)assert.equal(plain.displayName, 'Hermes')// Malformed commit values must not leak into the name (commit builds// validate the full SHA elsewhere; the display derivation stays total).process.env.HERMES_BUILD_COMMIT = 'not-a-sha'- const malformed = await identityForVariant(undefined)+ const malformed: ProductIdentity = await identityForVariant(undefined)assert.equal(malformed.displayName, 'Hermes')})-test('packaging isolates boot metadata and executable names without renaming release artifacts', async () => {- const pkg = require('../package.json')+test('packaging isolates boot metadata and executable names without renaming release artifacts', async (): Promise<void> => {+ const pkg: { name: string; productName: string; version: string; description: string } = require('../package.json')- const load = () => {+ const load: () => PackagingConfiguration = (): PackagingConfiguration => {delete require.cache[require.resolve('../electron-builder.config.cjs')]return require('../electron-builder.config.cjs')}- const stableIdentity = await identityForVariant('bundled')- const stable = load()+ const stableIdentity: ProductIdentity = await identityForVariant('bundled')+ const stable: PackagingConfiguration = load()assert.equal(stable.extraMetadata.productName || pkg.productName, pkg.productName)for (const build of ['canary', 'abcdef1234567890abcdef1234567890abcdef12']) {process.env.HERMES_PAYLOAD_TAG = build === 'canary' ? 'v0.28.0-canary.20260818' : ''process.env.HERMES_BUILD_COMMIT = build === 'canary' ? '' : build- const identity = await identityForVariant('bundled')- const config = load()+ const identity: ProductIdentity = await identityForVariant('bundled')+ const config: PackagingConfiguration = load()// Electron bootstrap gives productName precedence over name. appId alone// changes neither its early userData lookup nor its single-instance lock.assert.equal(config.extraMetadata.productName, identity.displayName)assert.equal(config.extraMetadata.name, identity.appNamePascal)assert.notEqual(config.extraMetadata.name, stableIdentity.appNamePascal)assert.equal(config.win.executableName, identity.windowsExecutableName)- const { AppInfo } = require('../../../node_modules/app-builder-lib/dist/appInfo.js')- const appInfo = new AppInfo({ config, metadata: { ...pkg, ...config.extraMetadata } }, null, config.win)++ const {+ AppInfo+ }: { AppInfo: typeof BuilderAppInfo } = require('../../../node_modules/app-builder-lib/dist/appInfo.js')++ const appInfo: BuilderAppInfo = new AppInfo(+ { config, metadata: { ...pkg, ...config.extraMetadata } } as Packager,+ null,+ config.win+ )+// Windows packaging, afterPack, rollback preservation and final signing// all consume this resolved name, not the display name.assert.equal(appInfo.productFilename, identity.windowsExecutableName)assert.equal(config.mac.extendInfo.CFBundleExecutable, config.executableName)assert.equal(config.artifactName, stable.artifactName)- const { appIdentity } = require('../../../scripts/msix-shared.mjs')++ const {+ appIdentity+ }: {+ appIdentity: (desktopDir: string) => { name: string; identity: ProductIdentity }+ } = require('../../../scripts/msix-shared.mjs')+process.env.HERMES_PAYLOAD_VERSION = '0.28.0'- const artifact = appIdentity(fileURLToPath(new URL('../', import.meta.url)))+ const artifact: ReturnType<typeof appIdentity> = appIdentity(fileURLToPath(new URL('../', import.meta.url)))assert.equal(artifact.name, identity.artifactNamePascal)assert.equal(artifact.identity.msixAppIdWithOrg, config.msix.identityName)assert.deepEqual(config.protocols[0].schemes, ['hermes'])@@ -223,7 +277,7 @@ test('packaging isolates boot metadata and executable names without renaming rel}})-test('stable tags and tagless dev builds publish to the stable channels', async () => {+test('stable tags and tagless dev builds publish to the stable channels', async (): Promise<void> => {process.env.HERMES_PAYLOAD_TAG = 'v0.28.0'assert.equal((await identityForVariant(undefined)).channel, 'latest')@@ -231,9 +285,9 @@ test('stable tags and tagless dev builds publish to the stable channels', asyncassert.equal((await identityForVariant('light')).channel, 'light')})-test('bundled variant has a distinct identity from the full variant', async () => {- const full = await identityForVariant(undefined)- const bundled = await identityForVariant('bundled')+test('bundled variant has a distinct identity from the full variant', async (): Promise<void> => {+ const full: ProductIdentity = await identityForVariant(undefined)+ const bundled: ProductIdentity = await identityForVariant('bundled')assert.equal(bundled.light, false)assert.notEqual(bundled.displayName, full.displayName)@@ -242,9 +296,9 @@ test('bundled variant has a distinct identity from the full variant', async () =assert.equal(bundled.channel, 'latest')})-test('store inherits the bundled app identity (shared userData) but swaps the MSIX packaging identity', async () => {- const bundled = await identityForVariant('bundled')- const store = await identityForVariant('store')+test('store inherits the bundled app identity (shared userData) but swaps the MSIX packaging identity', async (): Promise<void> => {+ const bundled: ProductIdentity = await identityForVariant('bundled')+ const store: ProductIdentity = await identityForVariant('store')// Same Electron app: displayName/appNamePascal (-> shared userData dir),// appId, and the out-of-store org-prefixed name are all inherited.@@ -258,7 +312,7 @@ test('store inherits the bundled app identity (shared userData) but swaps the MSassert.equal(store.channel, null)})-test('nonstable builds cannot claim the official Store package', async () => {+test('nonstable builds cannot claim the official Store package', async (): Promise<void> => {process.env.HERMES_PAYLOAD_TAG = 'v0.28.0-canary.20260818'await assert.rejects(identityForVariant('store'), /Store.*stable/)delete process.env.HERMES_PAYLOAD_TAG@@ -266,8 +320,8 @@ test('nonstable builds cannot claim the official Store package', async () => {await assert.rejects(identityForVariant('store'), /Store.*stable/)})-test('store carries the Partner Center MSIX identity and no other variant does', async () => {- const store = await identityForVariant('store')+test('store carries the Partner Center MSIX identity and no other variant does', async (): Promise<void> => {+ const store: ProductIdentity = await identityForVariant('store')assert.deepEqual(store.storeMsix, {identityName: 'NousResearchInc.HermesAgent',publisher: 'CN=EE6D86E4-606F-4E38-B940-AD7248C9D519',