@mobius-os/mobius 0.3.46 → 0.3.49

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mobius-os/mobius",
3
- "version": "0.3.46",
3
+ "version": "0.3.49",
4
4
  "type": "module",
5
5
  "description": "Mobius terminal client. Reuses Mobius frontend TypeScript types and jsonl entry shapes.",
6
6
  "bin": {
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 AIMUX_PACKAGE = 'aimux'
35
+ const AIMUX_TARGET_VERSION = '0.1.32'
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 = '3'
95
- const BUNDLE_AIMUX_VERSION = '0.1.29'
95
+ const BUNDLE_VER = '5'
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 (existsSync(aimuxExe()) && existsSync(venvPython())) { logInstall(`ensureAimux fast-path: venv aimux exe present\n`); onProgress?.({ phase: 'ready' }); return { ok: true, launcher: { kind: 'exe', path: aimuxExe() } } }
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`)
@@ -389,6 +389,12 @@ export function ChatScreen({ client, ready, webUserId, resumeSessionId, onClear,
389
389
  ? <WelcomeCard ready={ready} columns={terminal.columns} resumed={Boolean(resumeSessionId)} modelDisplay={modelDisplay} />
390
390
  : <CompactHeader ready={ready} sessionId={chat.sessionId} columns={terminal.columns} />}
391
391
 
392
+ {chat.switchedAway ? (
393
+ <Box flexShrink={0} borderStyle="round" borderColor="yellow" paddingX={1}>
394
+ <Text color="yellow" bold>注意:智能体已经离开此设备前往新设备({chat.switchedAway})</Text>
395
+ </Box>
396
+ ) : null}
397
+
392
398
  {!showWelcome
393
399
  ? <Box width="100%" flexShrink={0}><Text dimColor wrap="truncate-end"> {navigationPosition}{viewport.hasNewer ? <Text color="yellowBright">↓ 有新内容</Text> : null}{navigationDetail}</Text></Box>
394
400
  : null}
@@ -36,6 +36,8 @@ export interface ChatController {
36
36
  sending: boolean
37
37
  error: string | null
38
38
  sessionId: string | null
39
+ /** 智能体已离开本 TUI 设备、前往的新设备 ID; null = 未离开 (仍绑定本设备或非本设备会话). */
40
+ switchedAway: string | null
39
41
  send: (text: string) => Promise<void>
40
42
  stop: () => Promise<void>
41
43
  pauseToDequeue: () => Promise<void>
@@ -116,6 +118,7 @@ export function useChat({ client, ready, resumeSessionId }: ChatApi): ChatContro
116
118
  const [typing, setTyping] = useState(false)
117
119
  const [sending, setSending] = useState(false)
118
120
  const [error, setError] = useState<string | null>(null)
121
+ const [switchedAway, setSwitchedAway] = useState<string | null>(null)
119
122
  const sseRef = useRef<SseConnection | null>(null)
120
123
  // agent-history mini group store (协议 ①②③ 的 TUI 侧消费形态).
121
124
  const groupSlotsRef = useRef<Map<string, GroupSlot>>(new Map())
@@ -407,6 +410,14 @@ export function useChat({ client, ready, resumeSessionId }: ChatApi): ChatContro
407
410
  if (stopped || epoch !== statusEpochRef.current) return
408
411
  aliveRef.current = !!status.alive
409
412
 
413
+ // 设备切换检测: 本会话最初绑定本 TUI 设备 (initial_aimux_id == myId) 但当前已指向
414
+ // 别处 (aimux_id != myId) → 智能体"已离开本设备前往新设备". 用于渲染显眼提示 (仅 TUI 端).
415
+ const myId = tuiAimuxIdentifier()
416
+ const left = status.initial_aimux_id === myId && status.aimux_id && status.aimux_id !== myId
417
+ ? status.aimux_id
418
+ : null
419
+ setSwitchedAway(left)
420
+
410
421
  if (status.alive && status.working) {
411
422
  workingHintUntilRef.current = 0
412
423
  updateTyping(true)
@@ -552,5 +563,5 @@ export function useChat({ client, ready, resumeSessionId }: ChatApi): ChatContro
552
563
  pollNowRef.current?.()
553
564
  }, [sessionId, client])
554
565
 
555
- return { entries, pendingUser, pending, typing, sending, error, sessionId, send, stop, pauseToDequeue }
566
+ return { entries, pendingUser, pending, typing, sending, error, sessionId, switchedAway, send, stop, pauseToDequeue }
556
567
  }
package/src/types.ts CHANGED
@@ -84,6 +84,7 @@ export interface Issue {
84
84
  export interface PcClientMetadata {
85
85
  work_mode: 'hub' | 'pc' | 'dual'
86
86
  aimux_id: string
87
+ initial_aimux_id?: string
87
88
  local_path?: string
88
89
  is_tui: boolean
89
90
  add_remote_aimux_mcp?: boolean
@@ -137,6 +138,8 @@ export interface SessionRuntimeStatus {
137
138
  agent_backend?: string
138
139
  real_time_info?: string
139
140
  model_available?: boolean
141
+ aimux_id?: string | null
142
+ initial_aimux_id?: string | null
140
143
  }
141
144
 
142
145
  // ── Preferences lookups ──────────────────────────────────────────────────────