FIX: QVAC (QuantumVerse Automatic Computer) Packing
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* Bundle a lean QVAC Bare worker for the current (or env-specified) host.
|
||||
*
|
||||
* Used for local dev / pear. Electron Forge packaging runs the same logic via
|
||||
* `@qvac/sdk/electron-forge` (QvacForgePlugin).
|
||||
*
|
||||
* Env:
|
||||
* PEARDATA_PACKAGE_PLATFORM / PEARDATA_PACKAGE_ARCH — optional target
|
||||
* PEARDATA_SKIP_QVAC=1 — no-op exit 0
|
||||
*
|
||||
* @see https://docs.qvac.tether.io (qvac bundle sdk / electron-forge)
|
||||
*/
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
|
||||
const root = path.resolve(__dirname, '..')
|
||||
|
||||
async function main() {
|
||||
if (process.env.PEARDATA_SKIP_QVAC === '1') {
|
||||
console.log('[build-qvac-worker] skipped (PEARDATA_SKIP_QVAC=1)')
|
||||
return
|
||||
}
|
||||
|
||||
let commands
|
||||
try {
|
||||
commands = await import('@qvac/sdk/commands')
|
||||
} catch (err) {
|
||||
console.warn(
|
||||
'[build-qvac-worker] @qvac/sdk/commands unavailable — install @qvac/sdk for full LLM packaging.',
|
||||
err?.message || err
|
||||
)
|
||||
process.exitCode = 0
|
||||
return
|
||||
}
|
||||
|
||||
const platform = process.env.PEARDATA_PACKAGE_PLATFORM || process.platform
|
||||
const arch = process.env.PEARDATA_PACKAGE_ARCH || process.arch
|
||||
const host = `${platform}-${arch}`
|
||||
const configPath = path.join(root, 'qvac.config.json')
|
||||
|
||||
console.log(`[build-qvac-worker] bundleSdk hosts=${host}`)
|
||||
const result = await commands.bundleSdk({
|
||||
projectRoot: root,
|
||||
hosts: [host],
|
||||
...(fs.existsSync(configPath) ? { configPath } : {}),
|
||||
})
|
||||
|
||||
console.log(
|
||||
`[build-qvac-worker] ok addons=${(result.addons || []).length} bundle=${result.bundlePath || '(default)'}`
|
||||
)
|
||||
|
||||
if (typeof commands.verifyBundle === 'function') {
|
||||
const verify = await commands.verifyBundle({
|
||||
projectRoot: root,
|
||||
hosts: [host],
|
||||
...(result.bundlePath ? { addonsSource: result.bundlePath } : {}),
|
||||
})
|
||||
if (commands.hasErrors?.(verify)) {
|
||||
const msg =
|
||||
typeof commands.formatVerifyBundleResult === 'function'
|
||||
? commands.formatVerifyBundleResult(verify)
|
||||
: JSON.stringify(verify)
|
||||
throw new Error(`verifyBundle failed:\n${msg}`)
|
||||
}
|
||||
console.log('[build-qvac-worker] verifyBundle ok')
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error('[build-qvac-worker] failed:', err)
|
||||
process.exit(1)
|
||||
})
|
||||
+7
-2
@@ -9,8 +9,9 @@
|
||||
* Env:
|
||||
* PEARDATA_SERVER_HOSTS=linux-x64,linux-arm64
|
||||
* PEARDATA_CLIENT_HOSTS=linux-x64,darwin-arm64,…
|
||||
* PEARDATA_CLIENT_TIMEOUT_MS=600000
|
||||
* PEARDATA_CLIENT_TIMEOUT_MS=600000 (raise when packaging QVAC natives)
|
||||
* PEARDATA_SKIP_ELECTRON_PREDOWNLOAD=1
|
||||
* PEARDATA_SKIP_QVAC=1 tools-only Electron client (no @qvac/sdk bundle)
|
||||
*/
|
||||
'use strict'
|
||||
|
||||
@@ -28,7 +29,11 @@ const root = path.resolve(__dirname, '..')
|
||||
|
||||
const SERVER_HOSTS = parseHostList(process.env.PEARDATA_SERVER_HOSTS, SERVER_LINUX)
|
||||
const CLIENT_HOSTS = parseHostList(process.env.PEARDATA_CLIENT_HOSTS, ALL_64)
|
||||
const CLIENT_TIMEOUT_MS = Number(process.env.PEARDATA_CLIENT_TIMEOUT_MS || 600_000)
|
||||
// QVAC native bundle + forge package is heavier than the old asar-only client
|
||||
const CLIENT_TIMEOUT_MS = Number(
|
||||
process.env.PEARDATA_CLIENT_TIMEOUT_MS ||
|
||||
(process.env.PEARDATA_SKIP_QVAC === '1' ? 600_000 : 1_200_000)
|
||||
)
|
||||
|
||||
function run(cmd, args, opts = {}) {
|
||||
console.log(`\n$ ${cmd} ${args.join(' ')}\n`)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Optional combined Pear pre-hook (pear-electron + QVAC).
|
||||
*
|
||||
* Pear only allows one `pre` process to own pear-pipe. By default package.json
|
||||
* keeps `"pre": "pear-electron/pre"` so the desktop shell always boots.
|
||||
*
|
||||
* To also regenerate `qvac/worker.pear.entry.mjs` on every pear run/stage:
|
||||
* 1. Ensure `@qvac/sdk` is installed in this project
|
||||
* 2. Set `"pear.pre": "./scripts/pear-pre.mjs"`
|
||||
*
|
||||
* Or run once: `npm run build:qvac-worker`
|
||||
*
|
||||
* @see https://docs.qvac.tether.io (pear-pre)
|
||||
* @see node_modules/pear-electron/README.md
|
||||
*/
|
||||
|
||||
// Import pear-electron first so its pipe handler registers.
|
||||
import 'pear-electron/pre'
|
||||
|
||||
// QVAC pear-pre also speaks pear-pipe — only works if pear-electron re-exports
|
||||
// configuration instead of exclusive pipe ownership. Soft-fail if unavailable.
|
||||
try {
|
||||
await import('@qvac/sdk/pear-pre')
|
||||
} catch (err) {
|
||||
console.warn('[peardata] @qvac/sdk/pear-pre not applied:', err?.message || err)
|
||||
}
|
||||
Reference in New Issue
Block a user