@mobius-os/mobius 0.3.47 → 0.3.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/aimux.ts +18 -4
package/package.json
CHANGED
package/src/aimux.ts
CHANGED
|
@@ -32,7 +32,8 @@ export type AimuxLauncher =
|
|
|
32
32
|
| { kind: 'exe'; path: string }
|
|
33
33
|
| { kind: 'module'; python: string }
|
|
34
34
|
|
|
35
|
-
const
|
|
35
|
+
const AIMUX_TARGET_VERSION = '0.1.34'
|
|
36
|
+
const AIMUX_PACKAGE = `aimux==${AIMUX_TARGET_VERSION}`
|
|
36
37
|
const WIN = process.platform === 'win32'
|
|
37
38
|
const venvDir = () => path.join(mobiusHome(), 'aimux-venv')
|
|
38
39
|
const venvPython = () => WIN ? path.join(venvDir(), 'Scripts', 'python.exe') : path.join(venvDir(), 'bin', 'python')
|
|
@@ -91,8 +92,8 @@ async function pythonForAimux(onProgress?: (p: InstallProgress) => void): Promis
|
|
|
91
92
|
// 解压到 ~/.mobius/python-bundle/ 后用 `<python> -m aimux` 运行,彻底绕开宿主机
|
|
92
93
|
// 系统 python(如被精简掉 ensurepip 的容器镜像)。aimux 全部依赖为纯 Python,
|
|
93
94
|
// 故三平台可共用同一套打包产物,分别按 arch 发布到 CDN。
|
|
94
|
-
const BUNDLE_VER = '
|
|
95
|
-
const BUNDLE_AIMUX_VERSION =
|
|
95
|
+
const BUNDLE_VER = '6'
|
|
96
|
+
const BUNDLE_AIMUX_VERSION = AIMUX_TARGET_VERSION
|
|
96
97
|
/** Version expected from the installed or bundled AIMUX runtime. */
|
|
97
98
|
export const AIMUX_VERSION = BUNDLE_AIMUX_VERSION
|
|
98
99
|
const bundleDir = () => path.join(mobiusHome(), 'python-bundle')
|
|
@@ -274,9 +275,22 @@ export function spawnLauncher(launcher: AimuxLauncher, args: string[]): ChildPro
|
|
|
274
275
|
/** test-only 导出: 暴露内部 downloadBundle 以便单测 mock fetch 验证流式下载+进度。 */
|
|
275
276
|
export const downloadBundleForTest = downloadBundle
|
|
276
277
|
|
|
278
|
+
function venvReady(): boolean {
|
|
279
|
+
if (!existsSync(aimuxExe()) || !existsSync(venvPython())) return false
|
|
280
|
+
try {
|
|
281
|
+
return spawnSync(
|
|
282
|
+
venvPython(),
|
|
283
|
+
['-c', `import aimux; assert aimux.__version__ == '${AIMUX_TARGET_VERSION}'`],
|
|
284
|
+
{ stdio: 'ignore', windowsHide: true },
|
|
285
|
+
).status === 0
|
|
286
|
+
} catch {
|
|
287
|
+
return false
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
277
291
|
export async function ensureAimux(onProgress?: (p: InstallProgress) => void): Promise<{ ok: boolean; error?: string; launcher?: AimuxLauncher }> {
|
|
278
292
|
// Fast-path:venv 里已有 aimux 可执行 → 直接用。
|
|
279
|
-
if (
|
|
293
|
+
if (venvReady()) { logInstall(`ensureAimux fast-path: venv aimux ${AIMUX_TARGET_VERSION} present\n`); onProgress?.({ phase: 'ready' }); return { ok: true, launcher: { kind: 'exe', path: aimuxExe() } } }
|
|
280
294
|
logInstall(`\n########## ensureAimux install begin ${new Date().toISOString()} platform=${process.platform} arch=${process.arch} home=${mobiusHome()} ##########\n`)
|
|
281
295
|
const py = await pythonForAimux(onProgress)
|
|
282
296
|
logInstall(` pythonForAimux → ${py ?? '(null: no system python)'}\n`)
|