@mobius-os/mobius 0.3.61 → 0.3.62
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/README.md +3 -2
- package/package.json +1 -1
- package/scripts/build-python-bundles.sh +3 -3
- package/src/App.tsx +2 -1
- package/src/aimux.ts +121 -17
- package/src/components/Chat.tsx +12 -2
- package/tests/aimux.test.tsx +16 -3
- package/tests/ui.test.tsx +35 -0
package/README.md
CHANGED
|
@@ -95,8 +95,9 @@ to green.
|
|
|
95
95
|
`<Static>` rows with dynamic UI.
|
|
96
96
|
- The `typing` event drives the working indicator. Press Esc (or Ctrl+C) to
|
|
97
97
|
interrupt a running turn.
|
|
98
|
-
- Slash commands: `/clear` (new session), `/resume` (history), `/
|
|
99
|
-
|
|
98
|
+
- Slash commands: `/clear` (new session), `/resume` (history), `/upgrade`
|
|
99
|
+
(install the newest AIMUX from PyPI and reconnect), `/help`, `/quit`.
|
|
100
|
+
Ctrl+C stops a running turn, or quits when idle.
|
|
100
101
|
|
|
101
102
|
## Reusing the web frontend
|
|
102
103
|
|
package/package.json
CHANGED
|
@@ -13,10 +13,10 @@ set -euo pipefail
|
|
|
13
13
|
|
|
14
14
|
TAG=20241002
|
|
15
15
|
PYVER=3.12.7
|
|
16
|
-
BUNDLE_VER=
|
|
17
|
-
AIMUX_VERSION=0.3.
|
|
16
|
+
BUNDLE_VER=12
|
|
17
|
+
AIMUX_VERSION=0.3.62
|
|
18
18
|
PYPI_INDEX=https://pypi.org/simple
|
|
19
|
-
WORK="${WORK
|
|
19
|
+
WORK="${WORK:-$HOME/python-bundles}"
|
|
20
20
|
DIST="${DIST:-$WORK/dist}"
|
|
21
21
|
AIMUX_WHEEL="${AIMUX_WHEEL:-}"
|
|
22
22
|
mkdir -p "$WORK" "$DIST"
|
package/src/App.tsx
CHANGED
|
@@ -19,7 +19,7 @@ import { ChatScreen } from './components/Chat.js'
|
|
|
19
19
|
import type { ConfigResult } from './components/ConfigFlow.js'
|
|
20
20
|
import { ResumePicker } from './components/ResumePicker.js'
|
|
21
21
|
import { Screen } from './components/Screen.js'
|
|
22
|
-
import { startAimuxConnection, stopAimuxConnection, type AimuxStatus } from './aimux.js'
|
|
22
|
+
import { startAimuxConnection, stopAimuxConnection, upgradeAimuxRuntime, type AimuxStatus } from './aimux.js'
|
|
23
23
|
import { AimuxStatusLine } from './components/AimuxStatus.js'
|
|
24
24
|
import { bufferUnclaimedInput, useStableInput } from './components/primitives.js'
|
|
25
25
|
|
|
@@ -200,6 +200,7 @@ export function App() {
|
|
|
200
200
|
onResume={onResume}
|
|
201
201
|
onQuit={onQuit}
|
|
202
202
|
onLogout={() => { void onLogout() }}
|
|
203
|
+
onUpgradeAimux={() => { void upgradeAimuxRuntime() }}
|
|
203
204
|
onReconfigure={onReconfigure}
|
|
204
205
|
onConfigCancel={onConfigCancel}
|
|
205
206
|
aimuxStatus={aimuxStatus}
|
package/src/aimux.ts
CHANGED
|
@@ -32,7 +32,7 @@ export type AimuxLauncher =
|
|
|
32
32
|
| { kind: 'exe'; path: string }
|
|
33
33
|
| { kind: 'module'; python: string }
|
|
34
34
|
|
|
35
|
-
const AIMUX_TARGET_VERSION = '0.3.
|
|
35
|
+
const AIMUX_TARGET_VERSION = '0.3.62'
|
|
36
36
|
const AIMUX_PACKAGE = `aimux==${AIMUX_TARGET_VERSION}`
|
|
37
37
|
const WIN = process.platform === 'win32'
|
|
38
38
|
const venvDir = () => path.join(mobiusHome(), 'aimux-venv')
|
|
@@ -92,7 +92,8 @@ async function pythonForAimux(onProgress?: (p: InstallProgress) => void): Promis
|
|
|
92
92
|
// 解压到 ~/.mobius/python-bundle/ 后用 `<python> -m aimux` 运行,彻底绕开宿主机
|
|
93
93
|
// 系统 python(如被精简掉 ensurepip 的容器镜像)。aimux 全部依赖为纯 Python,
|
|
94
94
|
// 故三平台可共用同一套打包产物,分别按 arch 发布到 CDN。
|
|
95
|
-
|
|
95
|
+
/** Plan B 内置运行时包版本;每次发版跟 aimux pin 一起 +1,测试也从这里取。 */
|
|
96
|
+
export const BUNDLE_VER = '12'
|
|
96
97
|
const BUNDLE_AIMUX_VERSION = AIMUX_TARGET_VERSION
|
|
97
98
|
/** Version expected from the installed or bundled AIMUX runtime. */
|
|
98
99
|
export const AIMUX_VERSION = BUNDLE_AIMUX_VERSION
|
|
@@ -288,22 +289,44 @@ function spawnDetachedDaemon(launcher: AimuxLauncher, args: string[]): ChildProc
|
|
|
288
289
|
/** test-only 导出: 暴露内部 downloadBundle 以便单测 mock fetch 验证流式下载+进度。 */
|
|
289
290
|
export const downloadBundleForTest = downloadBundle
|
|
290
291
|
|
|
291
|
-
|
|
292
|
-
|
|
292
|
+
/** `a >= b`(点分数字)。非数字段一律判 false,宁可重装也不要用一个看不懂的版本。 */
|
|
293
|
+
export function versionAtLeast(a: string, b: string): boolean {
|
|
294
|
+
const pa = a.split('.'), pb = b.split('.')
|
|
295
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
296
|
+
const x = Number(pa[i] ?? 0), y = Number(pb[i] ?? 0)
|
|
297
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) return false
|
|
298
|
+
if (x !== y) return x > y
|
|
299
|
+
}
|
|
300
|
+
return true
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** venv 里现成的 aimux 版本(跑不起来时 null)。 */
|
|
304
|
+
function installedAimuxVersion(): string | null {
|
|
305
|
+
if (!existsSync(aimuxExe()) || !existsSync(venvPython())) return null
|
|
293
306
|
try {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
).status === 0
|
|
307
|
+
const r = spawnSync(venvPython(), ['-c', 'import aimux; print(aimux.__version__)'], { encoding: 'utf8', windowsHide: true })
|
|
308
|
+
if (r.status !== 0) return null
|
|
309
|
+
const v = (r.stdout ?? '').trim().split(/\s+/).pop()
|
|
310
|
+
return v || null
|
|
299
311
|
} catch {
|
|
300
|
-
return
|
|
312
|
+
return null
|
|
301
313
|
}
|
|
302
314
|
}
|
|
303
315
|
|
|
316
|
+
/**
|
|
317
|
+
* pin 是**最低可用版本**,不是精确版本:比它新的直接沿用。
|
|
318
|
+
* 否则用户 `/upgrade` 到 PyPI 最新版后,下一次连接(乃至下次启动)会被拽回 pin,
|
|
319
|
+
* 升级看着"没生效"。
|
|
320
|
+
*/
|
|
321
|
+
function venvReady(): boolean {
|
|
322
|
+
const installed = installedAimuxVersion()
|
|
323
|
+
return installed !== null && versionAtLeast(installed, AIMUX_TARGET_VERSION)
|
|
324
|
+
}
|
|
325
|
+
|
|
304
326
|
export async function ensureAimux(onProgress?: (p: InstallProgress) => void): Promise<{ ok: boolean; error?: string; launcher?: AimuxLauncher }> {
|
|
305
327
|
// Fast-path:venv 里已有 aimux 可执行 → 直接用。
|
|
306
|
-
|
|
328
|
+
const existing = venvReady() ? installedAimuxVersion() : null
|
|
329
|
+
if (existing) { logInstall(`ensureAimux fast-path: venv aimux ${existing} present (pin ${AIMUX_TARGET_VERSION})\n`); onProgress?.({ phase: 'ready' }); return { ok: true, launcher: { kind: 'exe', path: aimuxExe() } } }
|
|
307
330
|
logInstall(`\n########## ensureAimux install begin ${new Date().toISOString()} platform=${process.platform} arch=${process.arch} home=${mobiusHome()} ##########\n`)
|
|
308
331
|
const py = await pythonForAimux(onProgress)
|
|
309
332
|
logInstall(` pythonForAimux → ${py ?? '(null: no system python)'}\n`)
|
|
@@ -666,17 +689,21 @@ export class AimuxSupervisor {
|
|
|
666
689
|
|
|
667
690
|
let supervisor: AimuxSupervisor | null = null
|
|
668
691
|
let installing: Promise<void> | null = null
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
// `aimux reverse connect --help`. See reverseConnectArgs for why this is probed.
|
|
672
|
-
let cachedSilentFlag: string | null | undefined = undefined
|
|
692
|
+
/** 上一次 startAimuxConnection 的参数,供 `/upgrade` 重装后原地重连。 */
|
|
693
|
+
let lastStartOpts: StartOptions | null = null
|
|
673
694
|
|
|
674
|
-
|
|
695
|
+
interface StartOptions {
|
|
675
696
|
server: string
|
|
676
697
|
token: string
|
|
677
698
|
onStatus?: (s: AimuxStatus) => void
|
|
678
699
|
refreshToken?: () => Promise<string | null>
|
|
679
|
-
}
|
|
700
|
+
}
|
|
701
|
+
// Resolved Windows console-hiding flag for the installed aimux (undefined =
|
|
702
|
+
// not probed yet this process). Cached so reconnects reuse it without re-running
|
|
703
|
+
// `aimux reverse connect --help`. See reverseConnectArgs for why this is probed.
|
|
704
|
+
let cachedSilentFlag: string | null | undefined = undefined
|
|
705
|
+
|
|
706
|
+
export async function startAimuxConnection(opts: StartOptions): Promise<void> {
|
|
680
707
|
const onStatus = opts.onStatus ?? (() => {})
|
|
681
708
|
// Tests and explicitly opted-out users should not spawn a network worker.
|
|
682
709
|
if (process.env.MOBIUS_TUI_DISABLE_AIMUX === '1') {
|
|
@@ -686,6 +713,7 @@ export async function startAimuxConnection(opts: {
|
|
|
686
713
|
onStatus({ state: 'disabled', phase: 'idle', detail: 'AIMUX 测试连接已跳过' }); return
|
|
687
714
|
}
|
|
688
715
|
if (supervisor || installing) return
|
|
716
|
+
lastStartOpts = opts
|
|
689
717
|
installing = (async () => {
|
|
690
718
|
onStatus({ state: 'starting', phase: 'python', detail: '检查 Python 与 AIMUX 运行环境…' })
|
|
691
719
|
const ready = await ensureAimux(p => onStatus({
|
|
@@ -718,3 +746,79 @@ export async function stopAimuxConnection(): Promise<void> {
|
|
|
718
746
|
const current = supervisor; supervisor = null
|
|
719
747
|
await current?.stop()
|
|
720
748
|
}
|
|
749
|
+
|
|
750
|
+
/** SIGTERM 掉本工作区 runtime JSON 里记录的守护进程,并删掉该文件。
|
|
751
|
+
* 不这么做的话,新 supervisor 会按 pid 复用到刚升级前的旧 daemon。 */
|
|
752
|
+
async function stopDaemonFromRuntime(): Promise<void> {
|
|
753
|
+
const hash = aimuxWorkspaceHash()
|
|
754
|
+
const pid = (await readRuntime(hash))?.pid ?? null
|
|
755
|
+
if (pid !== null && pidAlive(pid)) {
|
|
756
|
+
try { process.kill(pid, 'SIGTERM') } catch { /* 已经退了 */ }
|
|
757
|
+
for (let i = 0; i < 30 && pidAlive(pid); i++) await new Promise(r => setTimeout(r, 100))
|
|
758
|
+
if (pidAlive(pid)) { try { process.kill(pid, 'SIGKILL') } catch { /* ignore */ } }
|
|
759
|
+
}
|
|
760
|
+
try { await fs.unlink(runtimePath(hash)) } catch { /* 本来就没有 */ }
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/** `/upgrade` 装的永远是 PyPI 上的最新版,故意不走 AIMUX_TARGET_VERSION 这条 pin。 */
|
|
764
|
+
const AIMUX_PYPI_INDEX = 'https://pypi.org/simple'
|
|
765
|
+
|
|
766
|
+
/** 从 PyPI 官方索引安装最新 aimux(不带版本约束),返回实际装上的版本。 */
|
|
767
|
+
async function installLatestAimux(onProgress?: (p: InstallProgress) => void): Promise<{ ok: boolean; version?: string; error?: string }> {
|
|
768
|
+
const py = await pythonForAimux(onProgress)
|
|
769
|
+
if (!py) return { ok: false, error: '未找到 Python 3.10+(或 uv),无法升级 AIMUX' }
|
|
770
|
+
if (!existsSync(venvPython())) {
|
|
771
|
+
onProgress?.({ phase: 'venv', detail: `创建 Python 虚拟环境(${py})…` })
|
|
772
|
+
let r = await run(py, ['-m', 'venv', venvDir()])
|
|
773
|
+
if (r.code !== 0 && py === 'py') r = await run(py, ['-3', '-m', 'venv', venvDir()])
|
|
774
|
+
if (r.code !== 0) return { ok: false, error: `venv 创建失败: ${r.stderr || r.stdout}` }
|
|
775
|
+
}
|
|
776
|
+
onProgress?.({ phase: 'install', detail: '正在从 PyPI 安装最新 aimux…' })
|
|
777
|
+
// --no-cache-dir:刚发布的版本可能还躺在 pip 的索引/包缓存里(TTL 内),
|
|
778
|
+
// 用户点 /upgrade 就是要立刻拿到新版本,宁可多下一次也不吃缓存。
|
|
779
|
+
const r = await run(venvPython(), [
|
|
780
|
+
'-m', 'pip', 'install', '--no-input', '--disable-pip-version-check',
|
|
781
|
+
'--upgrade', '--no-cache-dir', '--index-url', AIMUX_PYPI_INDEX, 'aimux',
|
|
782
|
+
], line => {
|
|
783
|
+
if (/downloading|collecting|installing|using cached|%\s*\d|━|─/i.test(line)) onProgress?.({ phase: 'install', detail: line.slice(0, 120) })
|
|
784
|
+
})
|
|
785
|
+
if (r.code !== 0) return { ok: false, error: `pip install 失败: ${r.stderr || r.stdout}` }
|
|
786
|
+
const v = await run(venvPython(), ['-c', 'import aimux; print(aimux.__version__)'])
|
|
787
|
+
const version = v.code === 0 ? v.stdout.trim().split(/\s+/).pop() : undefined
|
|
788
|
+
logInstall(`/upgrade installed aimux ${version ?? '(version unknown)'} from ${AIMUX_PYPI_INDEX}\n`)
|
|
789
|
+
return { ok: true, version }
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* `/upgrade`:把本地 AIMUX 升到 PyPI 上的最新版并原地重连。
|
|
794
|
+
*
|
|
795
|
+
* 顺序很关键——先停 TUI 的续租与旧守护进程,再装,最后用上次的连接参数重连:
|
|
796
|
+
* 否则 supervisor 会按旧 pid 把升级前的 daemon 复用回来,升级看起来"没生效"。
|
|
797
|
+
*/
|
|
798
|
+
export async function upgradeAimuxRuntime(): Promise<{ ok: boolean; version?: string; error?: string }> {
|
|
799
|
+
const opts = lastStartOpts
|
|
800
|
+
const onStatus = opts?.onStatus ?? (() => {})
|
|
801
|
+
if (process.env.MOBIUS_TUI_DISABLE_AIMUX === '1') {
|
|
802
|
+
const error = 'AIMUX 自动连接已关闭 (MOBIUS_TUI_DISABLE_AIMUX=1)'
|
|
803
|
+
onStatus({ state: 'disabled', phase: 'idle', detail: 'AIMUX 自动连接已关闭' })
|
|
804
|
+
return { ok: false, error }
|
|
805
|
+
}
|
|
806
|
+
if (!opts) return { ok: false, error: '尚未登录或 AIMUX 未启动,无法升级' }
|
|
807
|
+
logInstall(`\n########## /upgrade requested ${new Date().toISOString()} ##########\n`)
|
|
808
|
+
onStatus({ state: 'starting', phase: 'install', detail: '正在停止 AIMUX 守护进程…' })
|
|
809
|
+
await stopAimuxConnection()
|
|
810
|
+
await stopDaemonFromRuntime()
|
|
811
|
+
const installed = await installLatestAimux(p => onStatus({
|
|
812
|
+
state: 'starting',
|
|
813
|
+
phase: p.phase === 'ready' ? 'connecting' : p.phase,
|
|
814
|
+
detail: p.detail || (p.phase === 'ready' ? 'AIMUX 已就绪,准备连接…' : p.phase),
|
|
815
|
+
}))
|
|
816
|
+
if (!installed.ok) {
|
|
817
|
+
logInstall(`########## /upgrade FAILED: ${installed.error} ##########\n`)
|
|
818
|
+
onStatus({ state: 'failed', phase: 'idle', detail: `${installed.error} · 日志: ${aimuxLogPath()}` })
|
|
819
|
+
return { ok: false, error: installed.error }
|
|
820
|
+
}
|
|
821
|
+
onStatus({ state: 'starting', phase: 'connecting', detail: `AIMUX ${installed.version ?? '最新版'} 已安装,正在重新连接…` })
|
|
822
|
+
await startAimuxConnection(opts)
|
|
823
|
+
return { ok: true, version: installed.version }
|
|
824
|
+
}
|
package/src/components/Chat.tsx
CHANGED
|
@@ -40,6 +40,8 @@ interface ChatProps {
|
|
|
40
40
|
onResume: () => void
|
|
41
41
|
onQuit: () => void
|
|
42
42
|
onLogout: () => void
|
|
43
|
+
/** 可选,与 aimuxStatus 一样只在接了 AIMUX 的宿主里给;缺省时 /upgrade 不动作。 */
|
|
44
|
+
onUpgradeAimux?: () => void
|
|
43
45
|
onReconfigure: (result: ConfigResult) => void
|
|
44
46
|
onConfigCancel: (sessionId: string | null) => void
|
|
45
47
|
aimuxStatus?: AimuxStatus
|
|
@@ -64,10 +66,11 @@ const SLASH_COMMANDS = [
|
|
|
64
66
|
{ cmd: '/logout', desc: '断开当前连接并返回登录界面' },
|
|
65
67
|
{ cmd: '/help', desc: '显示帮助' },
|
|
66
68
|
{ cmd: '/version', desc: '显示 TUI、AIMUX 和运行环境版本' },
|
|
69
|
+
{ cmd: '/upgrade', desc: '从 PyPI 安装最新 AIMUX 并重连' },
|
|
67
70
|
{ cmd: '/quit', desc: '退出 TUI' },
|
|
68
71
|
]
|
|
69
72
|
|
|
70
|
-
export function ChatScreen({ client, ready, webUserId, resumeSessionId, onClear, onResume, onQuit, onLogout, onReconfigure, onConfigCancel, aimuxStatus }: ChatProps) {
|
|
73
|
+
export function ChatScreen({ client, ready, webUserId, resumeSessionId, onClear, onResume, onQuit, onLogout, onUpgradeAimux, onReconfigure, onConfigCancel, aimuxStatus }: ChatProps) {
|
|
71
74
|
const chat = useChat({ client, ready, resumeSessionId })
|
|
72
75
|
const [showHelp, setShowHelp] = useState(false)
|
|
73
76
|
// null means "follow the tail". A concrete anchor identifies the exact row
|
|
@@ -130,11 +133,18 @@ export function ChatScreen({ client, ready, webUserId, resumeSessionId, onClear,
|
|
|
130
133
|
}
|
|
131
134
|
case '/model': setConfigOpen(true); return true
|
|
132
135
|
case '/config': setReconfigOpen(true); return true
|
|
136
|
+
case '/upgrade': {
|
|
137
|
+
// 安装与重连进度都走 aimuxStatus(状态行),失败也会落进 aimuxStatus.detail,
|
|
138
|
+
// 所以这里只管触发,不额外弹错。
|
|
139
|
+
setVersionInfo(null)
|
|
140
|
+
onUpgradeAimux?.()
|
|
141
|
+
return true
|
|
142
|
+
}
|
|
133
143
|
case '/logout': onLogout(); return true
|
|
134
144
|
case '/quit': case '/exit': onQuit(); return true
|
|
135
145
|
default: return false
|
|
136
146
|
}
|
|
137
|
-
}, [aimuxStatus, chat, client.server, modelLabel, ready.prefs.model, onClear, onResume, onQuit, onLogout])
|
|
147
|
+
}, [aimuxStatus, chat, client.server, modelLabel, ready.prefs.model, onClear, onResume, onQuit, onLogout, onUpgradeAimux])
|
|
138
148
|
|
|
139
149
|
const onSubmit = useCallback((text: string) => {
|
|
140
150
|
const t = text.trim()
|
package/tests/aimux.test.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import os from 'node:os'
|
|
|
7
7
|
import path from 'node:path'
|
|
8
8
|
import { render } from 'ink-testing-library'
|
|
9
9
|
import { AimuxStatusLine } from '../src/components/AimuxStatus.js'
|
|
10
|
-
import { AimuxSupervisor, probeAimuxBridgeConnection, bundleArch, bundleUrl, spawnLauncher, ensureFromBundle, downloadBundleForTest, reverseConnectArgs, pickSilentFlag, aimuxLogPath, bundleHealthCheckCode, tuiAimuxIdentifier, AIMUX_VERSION } from '../src/aimux.js'
|
|
10
|
+
import { AimuxSupervisor, probeAimuxBridgeConnection, BUNDLE_VER, bundleArch, bundleUrl, spawnLauncher, ensureFromBundle, downloadBundleForTest, reverseConnectArgs, pickSilentFlag, versionAtLeast, aimuxLogPath, bundleHealthCheckCode, tuiAimuxIdentifier, AIMUX_VERSION } from '../src/aimux.js'
|
|
11
11
|
|
|
12
12
|
const delay = (ms: number) => new Promise<void>(resolve => setTimeout(resolve, ms))
|
|
13
13
|
let pass = 0, fail = 0
|
|
@@ -174,11 +174,11 @@ async function testBundleArchAndUrl() {
|
|
|
174
174
|
const arch = bundleArch()
|
|
175
175
|
ok(arch === 'linux-x64' || arch === 'win-x64' || arch === 'mac-x64', `bundleArch returns a supported arch on this host (${arch})`)
|
|
176
176
|
const before = bundleUrl('linux-x64')
|
|
177
|
-
ok(before.includes(
|
|
177
|
+
ok(before.includes(`mobius-python-linux-x64-v${BUNDLE_VER}`) && before.endsWith('.zip'), 'bundleUrl follows the fixed filename pattern')
|
|
178
178
|
const saved = process.env.MOBIUS_TUI_PYTHON_BUNDLE_URL
|
|
179
179
|
process.env.MOBIUS_TUI_PYTHON_BUNDLE_URL = 'https://example.test/cdn/'
|
|
180
180
|
try {
|
|
181
|
-
ok(bundleUrl('win-x64') ===
|
|
181
|
+
ok(bundleUrl('win-x64') === `https://example.test/cdn/mobius-python-win-x64-v${BUNDLE_VER}.zip`, 'MOBIUS_TUI_PYTHON_BUNDLE_URL overrides the CDN base and trims trailing slash')
|
|
182
182
|
} finally { if (saved === undefined) delete process.env.MOBIUS_TUI_PYTHON_BUNDLE_URL; else process.env.MOBIUS_TUI_PYTHON_BUNDLE_URL = saved }
|
|
183
183
|
}
|
|
184
184
|
|
|
@@ -226,6 +226,18 @@ function testPickSilentFlag() {
|
|
|
226
226
|
ok(pickSilentFlag(' --silent-v2 Hide console.', 'linux') === null, 'off-Windows → always null')
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
+
function testVersionAtLeast() {
|
|
230
|
+
console.log('\n[AIMUX 6c] aimux pin is a floor, not an exact match')
|
|
231
|
+
// /upgrade 装的是 PyPI 最新版,通常比 pin 新;不能被 pin 校验判成"没装好"又拽回去。
|
|
232
|
+
ok(versionAtLeast('0.3.62', '0.3.61'), 'newer aimux satisfies the pinned floor')
|
|
233
|
+
ok(versionAtLeast('0.3.61', '0.3.61'), 'exactly the pinned version satisfies the floor')
|
|
234
|
+
ok(versionAtLeast('0.4.0', '0.3.61'), 'a newer minor satisfies the floor')
|
|
235
|
+
ok(!versionAtLeast('0.3.60', '0.3.61'), 'an older aimux is still reinstalled')
|
|
236
|
+
ok(!versionAtLeast('0.1.40', '0.3.61'), 'the old 0.1.x line is still reinstalled')
|
|
237
|
+
ok(versionAtLeast('0.3.61.1', '0.3.61'), 'a longer version string compares by segment')
|
|
238
|
+
ok(!versionAtLeast('garbage', '0.3.61'), 'an unparseable version is treated as not-ready')
|
|
239
|
+
}
|
|
240
|
+
|
|
229
241
|
function testAimuxIdentifierScopesWorkspace() {
|
|
230
242
|
console.log('\n[AIMUX 6a] reverse client identifier workspace isolation')
|
|
231
243
|
const first = tuiAimuxIdentifier('same-host', '/work/project-a')
|
|
@@ -298,6 +310,7 @@ async function main() {
|
|
|
298
310
|
await testSpawnLauncher()
|
|
299
311
|
testReverseConnectArgs()
|
|
300
312
|
testPickSilentFlag()
|
|
313
|
+
testVersionAtLeast()
|
|
301
314
|
testAimuxIdentifierScopesWorkspace()
|
|
302
315
|
testBundleHealthCheck()
|
|
303
316
|
await testEnsureFromBundleReady()
|
package/tests/ui.test.tsx
CHANGED
|
@@ -1256,6 +1256,40 @@ async function testVersionSlash() {
|
|
|
1256
1256
|
} finally { restoreFetch() }
|
|
1257
1257
|
}
|
|
1258
1258
|
|
|
1259
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1260
|
+
// TEST 18 — /upgrade hands off to the host (install latest aimux + reconnect)
|
|
1261
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
1262
|
+
async function testUpgradeSlash() {
|
|
1263
|
+
console.log('\n[UI 18] /upgrade slash command')
|
|
1264
|
+
const client = new MobiusClient('http://mock.local', 'mock-jwt-token')
|
|
1265
|
+
const ready: ReadyState = {
|
|
1266
|
+
project: { id: 'p1', name: '测试项目' },
|
|
1267
|
+
issue: { id: 'i1', project_id: 'p1', title: '测试任务' },
|
|
1268
|
+
prefs: { model: 'codex', language: 'zh', excluded_skill_ids: [], excluded_memory_ids: [] },
|
|
1269
|
+
}
|
|
1270
|
+
installMock((url) => {
|
|
1271
|
+
if (url.includes('/events')) {
|
|
1272
|
+
return new Response(new RS({ start(c: any) { sseController = c; c.enqueue(enc.encode('event: subscribed\ndata: {"event":"subscribed","session":{}}\n\n')) } }), { status: 200, headers: { 'content-type': 'text/event-stream' } })
|
|
1273
|
+
}
|
|
1274
|
+
return jsonResponse({ error: 'no mock' }, 404)
|
|
1275
|
+
})
|
|
1276
|
+
try {
|
|
1277
|
+
let upgrades = 0
|
|
1278
|
+
const { stdin, lastFrame, unmount } = render(
|
|
1279
|
+
<ChatScreen client={client} ready={ready} webUserId="u" onClear={() => {}} onResume={() => {}} onQuit={() => {}} onLogout={() => {}} onUpgradeAimux={() => { upgrades += 1 }} onReconfigure={() => {}} onConfigCancel={() => {}} />,
|
|
1280
|
+
)
|
|
1281
|
+
await delay(60)
|
|
1282
|
+
// 打全了命令名弹窗就收起,所以先在只打了前缀时看菜单里有没有它。
|
|
1283
|
+
stdin.write('/upg'); await delay(40)
|
|
1284
|
+
const menu = lastFrame() ?? ''
|
|
1285
|
+
ok(menu.includes('/upgrade'), '/upgrade is offered in the slash-command menu')
|
|
1286
|
+
stdin.write('rade'); await delay(40)
|
|
1287
|
+
stdin.write('\r'); await delay(80)
|
|
1288
|
+
unmount()
|
|
1289
|
+
ok(upgrades === 1, '/upgrade calls the host upgrade hook exactly once')
|
|
1290
|
+
} finally { restoreFetch() }
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1259
1293
|
async function main() {
|
|
1260
1294
|
await testLogin()
|
|
1261
1295
|
await testChat()
|
|
@@ -1283,6 +1317,7 @@ async function main() {
|
|
|
1283
1317
|
await testSendRetries502()
|
|
1284
1318
|
await testCompactSlash()
|
|
1285
1319
|
await testVersionSlash()
|
|
1320
|
+
await testUpgradeSlash()
|
|
1286
1321
|
// cleanup temp home
|
|
1287
1322
|
try { fs.rmSync(TMP_HOME, { recursive: true, force: true }) } catch { /* ignore */ }
|
|
1288
1323
|
console.log(`\n==== UI RESULT: ${pass} passed, ${fail} failed ====\n`)
|