mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-17 04:11:35 +00:00
94 lines
3.7 KiB
JavaScript
94 lines
3.7 KiB
JavaScript
// The desktop product identity — THE single source for every name-shaped
|
|
// value a variant owns. HERMES_DESKTOP_VARIANT=light builds "Hermes
|
|
// Light", the remote-only client; everything else is full "Hermes".
|
|
//
|
|
// Consumed at build time by electron-builder.config.cjs (packaging
|
|
// identity). electron/product-identity.ts is the typed runtime accessor.
|
|
// @ts-check
|
|
/// <reference types="node" />
|
|
'use strict'
|
|
|
|
const variants = {
|
|
'': { display: 'Hermes', kebab: 'hermes', pascal: 'Hermes' },
|
|
light: {
|
|
display: 'Hermes Light',
|
|
kebab: 'hermes-light',
|
|
pascal: 'HermesLight'
|
|
},
|
|
bundled: {
|
|
display: 'Hermes Agent',
|
|
kebab: 'hermes-bundled',
|
|
pascal: 'HermesBundled'
|
|
}
|
|
}
|
|
|
|
const variant = process.env.HERMES_DESKTOP_VARIANT || ''
|
|
if (!['', 'light', 'bundled', 'store'].includes(variant)) {
|
|
throw new Error(`Unknown HERMES_DESKTOP_VARIANT ${variant}. expected one of (empty), light, bundled, store`)
|
|
}
|
|
|
|
// 'store' is a Store-submission packaging identity layered on the bundled
|
|
// variant: same Electron app (displayName/appId/appNamePascal -> shared
|
|
// userData + single-instance lock with the out-of-store install), different
|
|
// MSIX package identity. The Store re-signs on submission.
|
|
const store = variant === 'store'
|
|
const light = variant === 'light'
|
|
const name = variants[store ? 'bundled' : (variant || '')]
|
|
|
|
// The electron-updater feed channel this build PUBLISHES to. A canary
|
|
// tag (vX.Y.Z+canary.YYYYMMDDTHHMMSSZ) writes canary.yml / light-canary.yml;
|
|
// stable tags write latest.yml / light.yml. Keyed on the payload tag so
|
|
// the one release workflow serves both channels — a canary build can
|
|
// never overwrite the stable feed file, and vice versa.
|
|
const canary = /\+canary\.20\d{6}T\d{6}Z$/.test(process.env.HERMES_PAYLOAD_TAG || '')
|
|
|
|
// Nonstable installs own their package family and local desktop state. The
|
|
// seven-character commit suffix also names the CLI and fits MSIX's name cap.
|
|
const buildCommitEnv = process.env.HERMES_BUILD_COMMIT || ''
|
|
const buildCommit = /^[a-f0-9]{40}$/.test(buildCommitEnv) ? buildCommitEnv.slice(0, 7) : null
|
|
const displayName = buildCommit
|
|
? `${name.display} ${buildCommit}`
|
|
: canary
|
|
? `${name.display} Canary`
|
|
: name.display
|
|
|
|
const kebabSuffix = buildCommit ? `-${buildCommit}` : canary ? '-canary' : ''
|
|
const pascalSuffix = buildCommit ? `Commit${buildCommit}` : canary ? 'Canary' : ''
|
|
const cliName = `${light ? 'hermes-light' : 'hermes'}${kebabSuffix}`
|
|
if (store && (canary || buildCommit)) {
|
|
throw new Error('Store packaging is only eligible for stable releases')
|
|
}
|
|
|
|
/** @typedef {import("./product-identity.d.cts")} ProductIdentity */
|
|
|
|
/** @type {ProductIdentity} */
|
|
const identity = {
|
|
store,
|
|
light,
|
|
displayName,
|
|
appId: `com.nousresearch.${name.kebab}${kebabSuffix}`,
|
|
// Store and commit builds do not publish a release feed.
|
|
channel: store || buildCommit ? null : light ? (canary ? 'light-canary' : 'light') : (canary ? 'canary' : 'latest'),
|
|
appNamePascal: `${name.pascal}${pascalSuffix}`,
|
|
artifactNamePascal: name.pascal,
|
|
windowsExecutableName: kebabSuffix ? cliName : displayName,
|
|
cliName,
|
|
msixAppIdWithOrg: `NousResearch.${name.pascal}${pascalSuffix}`,
|
|
...(store
|
|
? {
|
|
storeMsix: {
|
|
// Partner Center publisher identity (the account's publisher ID) —
|
|
// validated + re-signed by the Store on submission.
|
|
identityName: 'NousResearchInc.HermesAgent',
|
|
publisher: 'CN=EE6D86E4-606F-4E38-B940-AD7248C9D519',
|
|
publisherDisplayName: 'Nous Research Inc.'
|
|
}
|
|
}
|
|
: {})
|
|
}
|
|
|
|
const { channelBuildRequest } = require('../../scripts/msix-shared.mjs')
|
|
const request = channelBuildRequest()
|
|
module.exports = request
|
|
? Object.freeze({ ...request.identity, store: false, light: false, channel: request.channel })
|
|
: identity
|