@simplexai/localmodels-darwin-x64 0.1.0-dev.63 → 0.1.0-dev.64

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.
Files changed (72) hide show
  1. package/bootstrap.identity +1 -1
  2. package/bootstrap.sha256 +71 -64
  3. package/modules/localmodels/__init__.py +1 -1
  4. package/modules/localmodels/app.py +15 -2
  5. package/modules/localmodels/catalog.json +34 -0
  6. package/modules/localmodels/catalog.py +26 -4
  7. package/modules/localmodels/catalog_recipes.py +37 -1
  8. package/modules/localmodels/context_policy.py +6 -1
  9. package/modules/localmodels/debug_mode.py +85 -103
  10. package/modules/localmodels/deploy.py +41 -6
  11. package/modules/localmodels/download-mirrors.json +126 -6
  12. package/modules/localmodels/draft_spec.py +122 -0
  13. package/modules/localmodels/engine_adapters/__init__.py +4 -0
  14. package/modules/localmodels/engine_adapters/auxiliary.py +27 -0
  15. package/modules/localmodels/engine_adapters/base.py +40 -0
  16. package/modules/localmodels/engine_adapters/strata_poly.py +57 -0
  17. package/modules/localmodels/engine_adapters/suite_plan.py +394 -0
  18. package/modules/localmodels/engines-prism-b12178-03ec600.json +7 -7
  19. package/modules/localmodels/install.py +15 -0
  20. package/modules/localmodels/library_convert.py +2 -8
  21. package/modules/localmodels/library_elastic.py +2 -118
  22. package/modules/localmodels/library_jobs.py +1 -2
  23. package/modules/localmodels/library_poly.py +3 -2
  24. package/modules/localmodels/library_pricing.py +122 -13
  25. package/modules/localmodels/library_serve.py +4 -6
  26. package/modules/localmodels/memcalc_cli.py +2 -2
  27. package/modules/localmodels/planning/__init__.py +3 -0
  28. package/modules/localmodels/{memcalc_load.py → planning/memcalc_load.py} +1 -1
  29. package/modules/localmodels/{sizecalc.py → planning/sizecalc.py} +1 -1
  30. package/modules/localmodels/service_deployment.py +2 -1
  31. package/modules/localmodels/sizecalc_cli.py +10 -2
  32. package/modules/localmodels/speech_worker_sensevoice.py +30 -0
  33. package/modules/localmodels/stack.py +2 -4
  34. package/modules/localmodels/stack_arena.py +2 -2
  35. package/modules/localmodels/stack_auto.py +1 -1
  36. package/modules/localmodels/stack_aux_gpu.py +4 -2
  37. package/modules/localmodels/stack_card.py +2 -2
  38. package/modules/localmodels/stack_cleanup.py +3 -2
  39. package/modules/localmodels/stack_compose.py +9 -1
  40. package/modules/localmodels/stack_ledger.py +2 -1
  41. package/modules/localmodels/stack_mcp.py +1 -1
  42. package/modules/localmodels/stack_memory.py +3 -3
  43. package/modules/localmodels/stack_run.py +16 -0
  44. package/modules/localmodels/stack_suite.py +4 -3
  45. package/modules/localmodels/stack_try.py +2 -1
  46. package/modules/localmodels/stack_up.py +15 -30
  47. package/modules/localmodels/stack_view_llm.py +12 -7
  48. package/modules/localmodels/stack_warm.py +6 -3
  49. package/modules/localmodels/stack_whatif.py +1 -1
  50. package/modules/localmodels/suite.py +6 -334
  51. package/modules/localmodels/tui_views.py +17 -2
  52. package/modules/localmodels/web/index.html +595 -226
  53. package/modules/localmodels/web/sizecalc/app.js +34 -40
  54. package/modules/localmodels/web/sizecalc/calc.js +3 -3
  55. package/modules/localmodels/web/sizecalc/page.html +4 -3
  56. package/modules/localmodels/web/view/fleet.html +18 -3
  57. package/modules/localmodels/web/view/fleet.js +135 -14
  58. package/modules/localmodels/web/view/i18n.js +4 -0
  59. package/modules/localmodels/web/view/index.html +16 -0
  60. package/modules/localmodels/web/view/nav.js +49 -0
  61. package/modules/localmodels/web/view/theme.js +1 -1
  62. package/modules/localmodels/web/view/view.css +51 -15
  63. package/modules/localmodels/web/view/view.js +22 -4
  64. package/modules/{simplex_localmodels-0.1.0.dev63.dist-info → simplex_localmodels-0.1.0.dev64.dist-info}/METADATA +1 -1
  65. package/modules/{simplex_localmodels-0.1.0.dev63.dist-info → simplex_localmodels-0.1.0.dev64.dist-info}/RECORD +68 -61
  66. package/package.json +1 -1
  67. package/tool.json +1 -1
  68. /package/modules/localmodels/{memcalc.py → planning/memcalc.py} +0 -0
  69. /package/modules/{simplex_localmodels-0.1.0.dev63.dist-info → simplex_localmodels-0.1.0.dev64.dist-info}/WHEEL +0 -0
  70. /package/modules/{simplex_localmodels-0.1.0.dev63.dist-info → simplex_localmodels-0.1.0.dev64.dist-info}/entry_points.txt +0 -0
  71. /package/modules/{simplex_localmodels-0.1.0.dev63.dist-info → simplex_localmodels-0.1.0.dev64.dist-info}/licenses/NOTICE +0 -0
  72. /package/modules/{simplex_localmodels-0.1.0.dev63.dist-info → simplex_localmodels-0.1.0.dev64.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -1,7 +1,7 @@
1
- """Plans for the stack components that are not catalog llama.cpp LLMs: Strata LLMs and the
1
+ """Recipes for the stack components that are not catalog llama.cpp LLMs: Strata LLMs and the
2
2
  embedding, reranker, STT and TTS servers on the CPU, plus the CUDA engine of a GPU
3
- decision model. Every part is a ``localmodels.deployment-plan/v1`` document that deploy.execute
4
- runs like any other; the recipes, artifacts and launch templates live in the catalog's
3
+ decision model. Every part is a ``localmodels.deployment-plan/v1`` document
4
+ (``engine_adapters.suite_plan.build_plan``) that deploy.execute runs like any other; the recipes, artifacts and launch templates live in the catalog's
5
5
  ``components`` list (``runtime`` strata | strata-poly | llama.cpp-cpu | whisper.cpp-cpu |
6
6
  kokoro-onnx-cpu). A recipe that names a ``venv`` runs in that hash-locked Python
7
7
  environment (frontend.install builds it) instead of a pinned engine build. A strata-poly recipe names both: PolyStrata's Python server (``{python}``, from
@@ -16,15 +16,11 @@ from __future__ import annotations
16
16
  import copy
17
17
  import json
18
18
  import subprocess
19
- import sys
20
- import urllib.parse
21
19
  from dataclasses import dataclass, field
22
20
  from pathlib import Path
23
- from typing import Any, TypedDict, cast
21
+ from typing import TypedDict
24
22
 
25
23
  from localmodels import catalog as cat
26
- from localmodels import hosts, reuse, vision
27
- from localmodels.component import front_venv, venv_python
28
24
  from localmodels.contracts import decode
29
25
  from localmodels.engines import (
30
26
  EngineUnavailableError,
@@ -33,17 +29,9 @@ from localmodels.engines import (
33
29
  release_engine,
34
30
  select_engine_build,
35
31
  )
36
- from localmodels.frontend import MIN_PYTHON
37
- from localmodels.plan_envelope import (
38
- MODELSCOPE_URL,
39
- PlanError,
40
- cpu_threads,
41
- deployment,
42
- plan_envelope,
43
- verified_in_place,
44
- )
32
+ from localmodels.plan_envelope import MODELSCOPE_URL, PlanError
45
33
  from localmodels.probe import GPU, HostFacts
46
- from localmodels.records import Plan, ReleaseEngine, ReusableFile
34
+ from localmodels.records import Plan, ReleaseEngine
47
35
  from localmodels.vision import StrataVision
48
36
 
49
37
  GIB = 1 << 30
@@ -211,322 +199,6 @@ def slice_memory() -> int:
211
199
  return 0
212
200
 
213
201
 
214
- def _engine(r: SuiteRecipe, facts: HostFacts, base_dir: str, backend: str) -> ReleaseEngine:
215
- build = select_engine_build(facts, backend, engine_lock_path(r["engine"]))
216
- return release_engine(build, base_dir)
217
-
218
-
219
- def _venv_engine(r: SuiteRecipe, base_dir: str) -> ReleaseEngine:
220
- """The Python of the recipe's hash-locked venv; the requirements file is its pin. stack is
221
- local-only, so the venv is made from the Python planning runs on."""
222
- if sys.version_info < MIN_PYTHON:
223
- need = ".".join(map(str, MIN_PYTHON))
224
- raise PlanError(
225
- f"its Python environment needs Python {need} or newer; this host has {sys.version.split()[0]}"
226
- )
227
- venv = front_venv(base_dir, r["venv"])
228
- return {"source": "venv", "binary": venv_python(venv), "build": r["venv"], "dir": venv}
229
-
230
-
231
- def _threads(r: SuiteRecipe, facts: HostFacts) -> int:
232
- return int(r["threads"]) if r.get("threads") else cpu_threads(facts)
233
-
234
-
235
- def _formatted(value: object, values: dict[str, str]) -> object:
236
- if isinstance(value, str):
237
- return value.format(**values)
238
- if isinstance(value, list):
239
- return [_formatted(v, values) for v in value]
240
- if isinstance(value, dict):
241
- return {k: _formatted(v, values) for k, v in value.items()}
242
- return value
243
-
244
-
245
- def _reuse(files: list[ReusableFile], specs: list[SuiteFile], roots: tuple[str, ...]) -> None:
246
- """Point each file at a same-size copy under a --reuse-from directory (at its catalog path)
247
- on the destination's filesystem; the download step hard-links it only after the SHA256
248
- matches. A copy elsewhere cannot be linked, so it is not counted as saved download."""
249
- for f, spec in zip(files, specs, strict=True):
250
- for root in roots:
251
- candidate = Path(root).expanduser() / spec["path"]
252
- if (
253
- candidate.is_file()
254
- and candidate.stat().st_size == f["size_bytes"]
255
- and candidate.stat().st_dev == reuse.device(str(Path(f["dest"]).expanduser()))
256
- ):
257
- f["reuse"] = str(candidate)
258
- break
259
-
260
-
261
- def _plan_files(
262
- r: SuiteRecipe, options: SuiteOptions, model_dir: str, reader: str
263
- ) -> list[ReusableFile]:
264
- template = SOURCES[r.get("source", "hf")]
265
- files: list[ReusableFile] = []
266
- specs = [
267
- f for f in cast("list[SuiteFile]", r["files"]) if reader != "off" or not f.get("vision")
268
- ]
269
- for f in specs: # catalog files may name their own source
270
- repo, revision = f.get("repo", r["repo"]), f.get("revision", r["revision"])
271
- url = "" if f.get("derived") else f.get("url") or template
272
- files.append(
273
- {
274
- "repo": repo,
275
- "path": f["path"],
276
- "revision": revision,
277
- "size_bytes": f["size_bytes"],
278
- "sha256": f["sha256"],
279
- "local_name": f.get("local_name", f["path"].rsplit("/", 1)[-1]),
280
- "dest": f"{model_dir}/{f.get('local_name', f['path'])}",
281
- "url": url.format(
282
- hf=options.hf_endpoint,
283
- repo=repo,
284
- revision=revision,
285
- path=urllib.parse.quote(f["path"]),
286
- catalog_dir=cat.CATALOG_PATH.parent,
287
- ),
288
- }
289
- )
290
- if f.get("derived"):
291
- files[-1]["generated"] = True
292
- _reuse(files, specs, options.reuse_from)
293
- missing = [
294
- s["path"]
295
- for f, s in zip(files, specs, strict=True)
296
- if s.get("derived") and not f.get("reuse") and not verified_in_place(f)
297
- ]
298
- if missing and not r.get("preparation"):
299
- raise PlanError(
300
- f"{r['id']} has no pinned preparation recipe for {len(missing)} generated files "
301
- f"(such as {missing[0]}); point --reuse-from at an existing Strata model directory"
302
- )
303
- return files
304
-
305
-
306
- def _profile_template(
307
- facts: HostFacts,
308
- r: SuiteRecipe,
309
- options: SuiteOptions,
310
- files: list[ReusableFile],
311
- values: dict[str, str],
312
- reader: str,
313
- ) -> dict[str, Any]:
314
- """Build the rendered Strata/PolyStrata ``strata-profile.json`` template."""
315
- profile_template = dict(r.get("profile") or {})
316
- if reader != "off":
317
- projector = next(f for f in files if f["local_name"] == r["vision"]["mmproj"])
318
- values["vision_mmproj"] = projector["dest"]
319
- cores = int(facts.get("cpu", {}).get("logical_cores") or 2)
320
- profile_template["vision"] = vision.strata_section(reader, cores, exe="{vision_exe}")
321
- if r["runtime"] == "strata":
322
- profile_template["args"] = [*cast("list[str]", profile_template["args"]), "--vision"]
323
- if options.gpu and r.get("card_args"):
324
- # Under --gpu-memory the reserve also holds what the share leaves out of the real card
325
- # (stack_gpu_memory.LEFT_OUT, stack_suite.poly_reserve_mib), so the room is counted on it.
326
- left_out = int(cast("dict[str, int]", options.gpu).get("share_left_out_bytes", 0))
327
- room = options.gpu["total_bytes"] + left_out - (options.vram_reserve_mib << 20)
328
- profile_template["args"] = [
329
- *cast("list[str]", profile_template["args"]),
330
- *(
331
- a
332
- for group in r["card_args"]
333
- if room >= group["at_least_bytes"]
334
- and facts["platform"] in group.get("platforms", [facts["platform"]])
335
- for a in group["args"]
336
- ),
337
- ]
338
- if options.reasoning_budget and r["runtime"] == "strata":
339
- # strata-<model>.json's default for requests that name none (Strata DETAILS, v0.2.4).
340
- profile_template["reasoning_budget_tokens"] = options.reasoning_budget
341
- if r["runtime"] == "strata-poly":
342
- # PolyStrata's server enables prompt-start warm-up only when opt-in warm_start is true,
343
- # and maps parallel: 2 to --batch 2 (WHI-1059 / WHI-1012).
344
- profile_template.setdefault("warm_start", True)
345
- profile_template.setdefault("parallel", 2)
346
- return profile_template
347
-
348
-
349
- def build_plan(host_id: str, facts: HostFacts, r: SuiteRecipe, options: SuiteOptions) -> Plan:
350
- """The deployment plan for one suite component from its catalog template."""
351
- base = options.base_dir.rstrip("/")
352
- on_gpu = r["runtime"] in STRATA_RUNTIMES or bool(r.get("vram_bytes"))
353
- if on_gpu and options.gpu is None:
354
- raise PlanError(f"{r['id']} needs an idle NVIDIA GPU")
355
- apple = facts["platform"] == "darwin" and facts["arch"] == "arm64"
356
- _check_runtime(facts, r)
357
- backend = ("metal" if apple else "cuda") if on_gpu else "cpu"
358
- engine = _engine(r, facts, base, backend) if r.get("engine") else _venv_engine(r, base)
359
- model_dir = f"{base}/models/{r['id']}"
360
- reader = options.vision_reader if r.get("vision") else "off"
361
- files = _plan_files(r, options, model_dir, reader)
362
- port = options.port or int(r.get("port") or 0)
363
- where = deployment(r["id"], port, base, taken=hosts.deployment_dirs(host_id))
364
- threads = _threads(r, facts)
365
- values = {
366
- "engine": engine["binary"],
367
- "engine_dir": engine["dir"],
368
- "vision_exe": f"{engine['dir']}/strata-vision.exe"
369
- if facts["platform"] == "win32"
370
- else f"{engine['dir']}/strata-vision",
371
- "model_dir": model_dir,
372
- "hf_endpoint": options.hf_endpoint,
373
- "model": files[0]["dest"] if files else model_dir,
374
- "weights_sha256": files[0]["sha256"] if files else "",
375
- "alias": r.get("alias", r["id"]),
376
- "port": str(where.port),
377
- "key_file": where.api_key_file,
378
- "deploy_dir": where.deploy_dir,
379
- "threads": str(threads),
380
- "gpu_uuid": options.gpu["uuid"] if options.gpu else "",
381
- "vram_reserve_mib": str(options.vram_reserve_mib),
382
- "expert_cache": options.expert_cache,
383
- "auth_proxy": f"{where.deploy_dir}/{AUTH_PROXY}",
384
- "tts_server": f"{where.deploy_dir}/{TTS_SERVER}",
385
- "poly_server": f"{where.deploy_dir}/{POLY_SERVER}",
386
- "python": venv_python(front_venv(base, r["venv"])) if r.get("venv") else "",
387
- }
388
- parking = r.get("conversation_cache")
389
- parking_mib = options.conversation_cache_mib if parking else 0
390
- reader_ram_mib = vision.strata_ram_mib(r.get("vision") or {}, reader)
391
- profile_template = _profile_template(facts, r, options, files, values, reader)
392
- if parking:
393
- values |= {
394
- "conversation_cache_mib": str(parking_mib),
395
- "conversation_cache_slots": str(parking["slots"]),
396
- "conversation_cache_min_free_mib": str(parking["min_free_mib"]),
397
- "conversation_cache_min_tokens": str(parking["min_tokens"]),
398
- }
399
- argv = [a.format(**values) for a in r["argv"]]
400
- argv[0] = (
401
- sys.executable
402
- if host_id == hosts.LOCAL_ID and r.get("auth_proxy") and argv[0] == "python3"
403
- else argv[0]
404
- )
405
- if apple and r["runtime"] in ("llama.cpp", "llama.cpp-cpu"):
406
- argv += ["--device", "MTL0" if on_gpu else "none"]
407
- env = {k: v.format(**values) for k, v in r.get("env", {}).items()}
408
- env.setdefault("CUDA_VISIBLE_DEVICES", values["gpu_uuid"])
409
- if r["runtime"] in ("llama.cpp-cpu", "whisper.cpp-cpu") or (
410
- on_gpu and r["runtime"] not in STRATA_RUNTIMES
411
- ):
412
- env.setdefault("LD_LIBRARY_PATH", engine["dir"])
413
- if apple:
414
- env.pop("CUDA_VISIBLE_DEVICES", None)
415
- env.pop("LD_LIBRARY_PATH", None)
416
- # Parked conversations live in the engine's own cgroup, so the budget raises its ceilings.
417
- added_mib = parking_mib + reader_ram_mib
418
- limits = {
419
- k: f"{(size_bytes(v) >> 20) + added_mib}M"
420
- if added_mib and k in ("MemoryHigh", "MemoryMax")
421
- else v
422
- for k, v in {**r.get("limits", {}), **NO_SWAP}.items()
423
- }
424
- label = f"GPU {options.gpu['index']}" if on_gpu and options.gpu else f"CPU {threads} threads"
425
- gpus = (
426
- [{"index": options.gpu["index"], "uuid": options.gpu["uuid"], "name": options.gpu["name"]}]
427
- if on_gpu and options.gpu
428
- else []
429
- )
430
- plan = plan_envelope(
431
- host_id,
432
- facts,
433
- where,
434
- model={
435
- "id": r["id"],
436
- "display_name": r.get("display_name") or f"{r.get('alias', r['id'])} ({r['runtime']})",
437
- "repo": r["repo"],
438
- "quant": r["version"],
439
- "model_id": r.get("alias", r["id"]),
440
- "validated": r.get("status") == "validated",
441
- },
442
- files=files,
443
- engine=engine,
444
- placement={
445
- "id": "gpu" if on_gpu else "cpu",
446
- "label": label,
447
- "pooled": False,
448
- "gpus": gpus,
449
- },
450
- launch={
451
- "window": r.get("context", 0),
452
- "spilled": False,
453
- "spill_bytes": 0,
454
- "reasons": [r.get("note", "")],
455
- "threads": threads,
456
- "memory_estimate_bytes": r["memory_estimate_bytes"] + (added_mib << 20),
457
- "vram_bytes": r.get("vram_bytes", 0)
458
- + (vision.strata_gpu_mib(r.get("vision") or {}, reader) << 20),
459
- **(
460
- {"preparation": _formatted(r["preparation"], values)}
461
- if r.get("preparation")
462
- else {}
463
- ),
464
- **({"conversation_cache_mib": parking_mib} if parking else {}),
465
- **_profile_launch(r["runtime"], profile_template),
466
- **({"vision": reader} if reader != "off" else {}),
467
- # The same keys as a decision front's: stack apply builds the venv before the unit.
468
- **(
469
- {
470
- "frontend_requirements": r["venv"],
471
- "frontend_base_dir": options.base_dir,
472
- "frontend_bytes": r.get("venv_bytes", 0),
473
- }
474
- if r.get("venv")
475
- else {}
476
- ),
477
- },
478
- service={
479
- "argv": argv,
480
- "env": env,
481
- "limits": limits,
482
- "slice": SLICE,
483
- "slice_limits": {**options.slice_limits, **NO_SWAP},
484
- },
485
- endpoint={"model": r.get("alias", r["id"]), "contract": r.get("contract", "chat")},
486
- warnings=[],
487
- )
488
- config: dict[str, str] = {}
489
- if profile_template:
490
- profile = _formatted(profile_template, values)
491
- config[f"{where.deploy_dir}/strata-profile.json"] = json.dumps(profile, indent=1) + "\n"
492
- if r.get("auth_proxy"):
493
- config[values["auth_proxy"]] = (PACKAGE_DIR / AUTH_PROXY).read_text(encoding="utf-8")
494
- if server := SERVERS.get(r["runtime"]):
495
- config[f"{where.deploy_dir}/{server}"] = (PACKAGE_DIR / server).read_text(encoding="utf-8")
496
- if config:
497
- plan["service"]["config_files"] = config
498
- if r.get("health_path"):
499
- plan["service"]["health_path"] = r["health_path"]
500
- _readiness(plan, r)
501
- return plan
502
-
503
-
504
- def _profile_launch(runtime: str, profile: dict[str, object]) -> dict[str, object]:
505
- if runtime not in STRATA_RUNTIMES:
506
- return {}
507
- launch: dict[str, object] = {"slots": int(str(profile.get("parallel") or 1))}
508
- args = cast("list[str]", profile.get("args") or [])
509
- if "--mtp" in args and "--spec" in args:
510
- launch["mtp_draft_depth"] = int(args[args.index("--spec") + 1])
511
- return launch
512
-
513
-
514
- def _readiness(plan: Plan, r: SuiteRecipe) -> None:
515
- """What the readiness check needs beyond the contract: its input, time and token limit."""
516
- if r.get("fixture"):
517
- plan["fixture"] = r["fixture"]
518
- if r.get("verify_timeout_s"):
519
- plan["verify_timeout_s"] = r["verify_timeout_s"]
520
- if r.get("input_tokens"):
521
- plan["input_tokens"] = r["input_tokens"]
522
-
523
-
524
- def _check_runtime(facts: HostFacts, recipe: SuiteRecipe) -> None:
525
- # PolyStrata's strata-poly has a Metal build; Strata's own engine is CUDA only.
526
- if facts["platform"] == "darwin" and recipe["runtime"] == "strata":
527
- raise PlanError("Strata recipes need CUDA and cannot run on Apple Silicon Metal")
528
-
529
-
530
202
  def cuda_decision_engine(
531
203
  facts: HostFacts, argv: list[str], base_dir: str, notes: list[str], *, metal: bool = False
532
204
  ) -> ReleaseEngine:
@@ -227,7 +227,16 @@ def _device_summary(facts: HostFacts | None) -> str:
227
227
  if facts is None:
228
228
  return "-"
229
229
  gpus = facts["gpus"]
230
- return f"{len(gpus)}×{gpus[0]['name']}" if gpus else facts["gpu_vendor_class"]
230
+ if not gpus:
231
+ return facts["gpu_vendor_class"]
232
+ counts: dict[str, int] = {}
233
+ for g in gpus:
234
+ name = g["name"]
235
+ counts[name] = counts.get(name, 0) + 1
236
+ groups = [f"{n}×{name}" if n > 1 else name for name, n in counts.items()]
237
+ if len(groups) <= 2:
238
+ return " + ".join(groups)
239
+ return f"{groups[0]} 等 {len(gpus)} 张卡"
231
240
 
232
241
 
233
242
  def devices_view(
@@ -436,6 +445,12 @@ def model_detail(m: CatalogRow) -> str:
436
445
  return f"{m.get('display_name', '')}({m.get('id', '')})" + (f":{summary}" if summary else "")
437
446
 
438
447
 
448
+ def _window_text(window: object) -> str:
449
+ if isinstance(window, int) and not isinstance(window, bool) and window >= 1024:
450
+ return stack_summary.window_label(window)
451
+ return str(window)
452
+
453
+
439
454
  def plan_view(device: str, plan: Plan | None) -> list[Line]:
440
455
  if plan is None:
441
456
  return [("还没有计划。在推荐页选中模型后按 Enter 生成(只读)。", "dim")]
@@ -462,7 +477,7 @@ def plan_view(device: str, plan: Plan | None) -> list[Line]:
462
477
  ]
463
478
  lines += [
464
479
  (
465
- f"窗口 {launch.get('window')}"
480
+ f"窗口 {_window_text(launch.get('window'))}"
466
481
  + (f",溢出到系统内存 {gib(int(str(spill)))}" if launch.get("spilled") else ",不溢出"),
467
482
  "warn" if launch.get("spilled") else "text",
468
483
  ),